filmov
tv
load json data using jquery ajax
Показать описание
Link for all dot net and sql server video tutorial playlists
Link for slides, code samples and text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
In this video we will discuss how to load JSON data from the server using jQuery get function. This is continuation to Part 56. Please watch Part 56 before proceeding.
Syntax
$.get( url [, data ] [, success ] [, dataType ] )
dataType parameter specifies the type of data expected from the server. The dataType can be xml, json, script, or html. By default jQuery makes an intelligent guess.
Replace < with LESSTHAN symbol and > with GREATERTHAN symbol
<div id="divResult" runat="server"></div>
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Script.Serialization;
namespace Demo
{
public partial class GetHelpText : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
JavaScriptSerializer js = new JavaScriptSerializer();
string JSONString = js.Serialize(GetHelpTextByKey(Request["HelpTextKey"]));
Response.Write(JSONString);
}
private HelpText GetHelpTextByKey(string key)
{
HelpText helpText = new HelpText();
string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("spGetHelpTextByKey", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(parameter);
con.Open();
helpText.Text = cmd.ExecuteScalar().ToString();
helpText.Key = key;
}
return helpText;
}
}
public class HelpText
{
public string Key { get; set; }
public string Text { get; set; }
}
}
$(document).ready(function () {
var textBoxes = $('input[type="text"]');
var helpDiv = $(this).attr('id');
$('#' + helpDiv + 'HelpDiv').html(response.Text);
}, 'json');
});
var helpDiv = $(this).attr('id') + 'HelpDiv';
$('#' + helpDiv).html('');
});
});
Link for slides, code samples and text version of the video
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
In this video we will discuss how to load JSON data from the server using jQuery get function. This is continuation to Part 56. Please watch Part 56 before proceeding.
Syntax
$.get( url [, data ] [, success ] [, dataType ] )
dataType parameter specifies the type of data expected from the server. The dataType can be xml, json, script, or html. By default jQuery makes an intelligent guess.
Replace < with LESSTHAN symbol and > with GREATERTHAN symbol
<div id="divResult" runat="server"></div>
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Web.Script.Serialization;
namespace Demo
{
public partial class GetHelpText : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
JavaScriptSerializer js = new JavaScriptSerializer();
string JSONString = js.Serialize(GetHelpTextByKey(Request["HelpTextKey"]));
Response.Write(JSONString);
}
private HelpText GetHelpTextByKey(string key)
{
HelpText helpText = new HelpText();
string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand("spGetHelpTextByKey", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add(parameter);
con.Open();
helpText.Text = cmd.ExecuteScalar().ToString();
helpText.Key = key;
}
return helpText;
}
}
public class HelpText
{
public string Key { get; set; }
public string Text { get; set; }
}
}
$(document).ready(function () {
var textBoxes = $('input[type="text"]');
var helpDiv = $(this).attr('id');
$('#' + helpDiv + 'HelpDiv').html(response.Text);
}, 'json');
});
var helpDiv = $(this).attr('id') + 'HelpDiv';
$('#' + helpDiv).html('');
});
});
Комментарии