繁体   English   中英

无法使用jQuery Ajax显示结果

[英]Unable to display results using jquery ajax

我正在尝试在页面上实现评论功能。 我在该页面上有一个itemID 。我想显示人们发表的有关itemID 123的评论。但是,到目前为止,我无法在我的页面上显示这些评论。 控制台中没有错误。

Javascript:

function mywall() {
    var url = serverURL() + "/viewwall.php"; //execute viewwall.php in the server

    itemID = decodeURIComponent(getUrlVars()["itemID"]);

    var JSONObject = {
        "itemID": decodeURIComponent(getUrlVars()["itemID"])
    };

    $.ajax({
        url: url,
        type: 'GET',
        data: JSONObject,
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        success: function (arr) {
            _mywallresult(arr); //success. execute _mywallresult()
        },
        error: function () {
            validationMsg();
        }
    });
}

function _mywallresult(arr) {
    var i;

    //for all the shouts returned by the server 
    for (i = 0; i < arr.length; i++) {
        //append the following:
        //<b>
        //time of posting </b>
        //<br/>
        //the message
        //<br>
        //userid
        $("#wallcontentset").append("<b>" + arr[i].timeofposting + "</b><br/>" + arr[i].message + "<hr>" + arr[i].userid);
    }
}

HTML:

<div data-role="content" class="ui-content" id="wallcontentset"></div>

尝试以下方法:

success: function (response) {
    _mywallresult(response.arr); 
},

暂无
暂无

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

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