简体   繁体   中英

JQUERY JSON response triggers parse error

I am trying to perform some basic operations with jquery json.

  var urlPath= encodeURIComponent('{"fields":"subject,course,unit,topic,lesson"}');
  $.ajax({

              url : 'http://abcd.org/proficiency.json?data'+urlpath,
              type : 'GET',
              dataType : 'jsonp',
              contentType: "application/json",
              success : function(data) {
              console.log("success");

              },
              error: function (XMLHttpRequest, textStatus, errorThrown) {
              console.log(XMLHttpRequest, textStatus, errorThrown);


   }
    });

The error callback is always triggers

Error... parsererror jQuery15001997238997904205_1298484897373 was not called.

How to fix it?

Thanks for reading..

The server is giving back invalid JSON, there is an extra }] and a missing , . It should be changed to this:

{
    "content": [
        {
            "topic": [
                {
                    "22920": 0.0003933333333333333
                },
                {
                    "22937": 0.14765555555555557
                },
                {
                    "22881": 0.0013955555555555555
                }
            ]
        }
    ],
    "message": [],
    "dateRange": [
        {}
    ],
    "paginate": {}
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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