读书人

用ajax获取后台数据返回json数据如

发布时间: 2014-01-17 15:01:00 作者: rapoo

用ajax获取后台数据,返回json数据,怎么在前台使用呢?
用ajax获取后台数据,返回json数据,如何在前台使用呢

用ajax获取后台数据,返回json数据,怎么在前台使用呢?

后台

                                                              


[解决办法]
看你的json数据是列表还是单个了,就一条就无需中括号了
context.Response.Write("{\"name\":无用户,\"id\":\"0\",\"company\":\"无用户\"}");

$(document).ready(function () {
$("#Button3").click(
function (SucCallback) {
$.ajax(
{
type: "get",
url: 'GridDatas.ashx', //后台处理程序
dataType: 'json', //接受数据格式
data: 'DataType=SearchCustomer&CustomerID=' + document.getElementById("Text3").value, //要传递的数据
function (dataJson) {
alert(dataJson.Name);
alert(dataJson.Id);
},
error: function () { alert("error"); }
});
})
})

读书人网 >asp.net

热点推荐