Uncaught SyntaxError: Unexpected token o

I have a web application that I am working on:

$("#post").click(function () {

    var u = $('#u').val();
    var j = $('#j').val();

    $.post("http://www.myweb.php", {
            u: u,
            j: j
        })
        .done(function (data) {


            var obj = jQuery.parseJSON(data);
            alert(obj.status );
            //alert("Data Loaded: " + data);
        });

});

      

When it tries to get JSON, I get:

Uncaught SyntaxError: Unexpected token o

      

+3


source to share


1 answer


You don't need to call .parseJSON()

. Your answer has already been parsed. You are getting this error because the object you are passing to is jQuery.parseJSON()

being converted to a string "[object Object]"

. The unexpected token is "o" in "object".



+8


source







All Articles