Why is this JSONP feed throwing “Unexpected Token” error?

后端 未结 2 411
闹比i
闹比i 2021-01-25 15:45

I\'m trying to grap this remote JSONP feed via jQuery.

Every time I try, I get an error of \"Uncaught SyntaxError: Unexpected token (\" or similar.

Am I doing

相关标签:
2条回答
  • 2021-01-25 16:09

    If you use dataType: 'jsonp' JQuery appends a callback url parameter to the request. The value of this parameter must be the function name of the callback function the server returns. As Eugene Retunsky already mentioned this is formatted incorrectly, also it seems that the server code is omitting the first character of the function name so jQuery_674... becomes Query_674... which will not work.

    0 讨论(0)
  • 2021-01-25 16:13

    Because this feed returns JSON, not a javascript function call:

    [{Query172031345640518702567_1334079878875({...
    

    But it should be:

    Query172031345640518702567_1334079878875({...
    

    I don't know if this service is under your control and you can changed it, or you just need to add some params to the URL (check the manual).

    Also the content type of the response should be application/javascript, not text/json.

    0 讨论(0)
提交回复
热议问题