Response.Clear();
Response.Write("[{\"demoData\":\"This Is The JSON Data\"}]");
Response.Flush();
Response.End();
$.ajax({
type: "post",
url: "JqueryCSMethodForm.asmx/GetDemoData",
dataType: "json",/*这句可用可不用,没有影响*/
contentType: "application/json; charset=utf-8",
success: function (data) {
$("input#showTime").val(eval('(' + data.d + ')')[0].demoData);
//这里有两种对数据的转换方式,两处理方式的效果一样//$("input#showTime").val(eval(data.d)[0].demoData);
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert(errorThrown);
}
});
[WebMethod]
public static string GetDemoData() {
return "[{\"demoData\":\"This Is The JSON Data\"}]";
}
这种方式和普通的aspx的页面处理是一样的所以这里就不多做解释了!
标签:源码搜藏 蔓蔓视频 爱看电影网
热门源码