简体   繁体   English

无法显示从jquery ajax调用返回的json数据

[英]cannot display json data returned from jquery ajax call

can somebody please tell me, how can I display json data returning from the ajax call. 可有人告诉我,我怎么能显示JSON数据从AJAX调用返回。 I am new to this. 我是新来的。

$.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. 上面是js文件。 should i need to do something on asp file directly to display it. 我应该需要做asp文件的东西,直接显示它。 if yes, then how? 如果是,那怎么办? please reply me soon. 请尽快回复我。 im stuck here and unable to display data here. 即时通讯卡在这里,无法在此处显示数据。 Its only diplaying this line: 它唯一显示这一行:

toJSON value :function (key) { return this.valueOf(); toJSON value:function(key){return this.valueOf(); } }

Your result is most likely rooted with a property named d. 您的结果很可能以名为d的属性为根。 Try modifying your success to use result.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集合的漏洞利用有关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM