日期:2014-05-17 浏览次数:20507 次
[{"Name":"Ajay Singh","Company":"Birlasoft Ltd.","Address":"LosAngeles California","Phone":"1204675","Country":"US"},{"Name":"Ajay Singh","Company":"Birlasoft Ltd.","Address":"D-195 Sector Noida","Phone":"1204675","Country":"India"}]
$.ajax({
url: "JSON.asmx/TestJSON",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: "{}",
success: function(json) {
alert("返回的json格式");
},
error: function(x, e) {
alert(x.responseText);
}, //============================
complete: function(x) {
alert(x.responseText);
}
});
//请问我怎么把JSON转换为字符串赋值给文本框
for (var i = 0; i < json.d.length; i++) {
alert(json.d[i].Name);
};
success: function(json) {
var jsondata = eval(json);
alert(jsondata.Name);
alert(jsondata.Company);
……
},