Home Unable to display results using jquery ajax
Reply: 1

Unable to display results using jquery ajax

queenie
1#
queenie Published in 2018-02-13 19:08:01Z

I am trying to implement a comment feature on my page. I have an itemID 123. on that page, I would like to display the comments that people have posted about itemID 123. However as of now, I am unable to display these comments on my page. There are no errors in the console.

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>
Danis
2#
Danis Reply to 2018-02-13 19:42:12Z

Try the following :

success: function (response) {
    _mywallresult(response.arr); 
},
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.617639 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO