can somebody please tell me, how can I display json data returning from the ajax call. I am new to this.
有人可以告诉我,如何显示从ajax调用返回的json数据。我是新来的。
$.ajaxSetup({
cache: false,
timeout: 5000
});
});
//String.prototype.toJSON;
var the_object = {};
function concatObject(obj) {
strArray = []; //new Array
for (prop in obj) {
strArray.push(prop + " value :" + obj[prop]);
}
return strArray.join();
}
//var ntid = "hhsh";
//document.writeln("httpRequest.responseText");
$(document).ready(function() {
$("button").ajaxStart(function() {
alert('Triggered ajaxStart handler.');
});
$("button").click(function() {
$.ajax({
type: "POST",
dataType: 'JSON',
//data: "{'ntid':'john'}",
//contentType: "application/json; charset=utf-8",
//processData: false,
url: "Testing.aspx/SendMessage",
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(textStatus);
},
success: function(result, txtStatus, httpRequest) {
alert(txtStatus);
//$('#status').html(httpRequest.responseText);
//the_object = result;
$('#status').html(concatObject(result));
//$('#status').html(the_object);
//alert("hello" + concatObject(the_object));
//document.writeln(concatObject(the_object));
}
});
//alert(concatObject(the_object));
//$('#status').html(concatObject(the_object));
});
});
above is the js file. should i need to do something on asp file directly to display it. if yes, then how? please reply me soon. i m stuck here and unable to display data here. Its only diplaying this line:
上面是js文件。我应该直接在asp文件上做一些事情来显示它。如果是,那怎么样?请尽快回复我我被困在这里,无法在这里显示数据。它只是在铺设这条线:
toJSON value :function (key) { return this.valueOf(); }
toJSON value:function(key){return this.valueOf(); }
1 个解决方案
#1
0
Your result is most likely rooted with a property named d. Try modifying your success to use result.d;
您的结果很可能是以名为d的属性为根。尝试修改您的成功以使用result.d;
This is usually a security measure that has to do with exploits which target a JSON collection with single root parent.
这通常是一种安全措施,它与针对具有单根父级的JSON集合的漏洞利用有关。
#1
0
Your result is most likely rooted with a property named d. Try modifying your success to use result.d;
您的结果很可能是以名为d的属性为根。尝试修改您的成功以使用result.d;
This is usually a security measure that has to do with exploits which target a JSON collection with single root parent.
这通常是一种安全措施,它与针对具有单根父级的JSON集合的漏洞利用有关。