简体   繁体   中英

Uncaught SyntaxError: Unexpected token : ajax jsonp

got an error of Uncaught SyntaxError: Unexpected token : from JSONP

here's my code

$(document).ready(function () {
        $.ajax({
            url: 'https://lc-txtconnect5.globe.com.ph/api/mts/validateuser',
            type: "GET",
            dataType: "jsonp",
            jsonpCallback: "localJsonpCallback"
        });
    });

   function localJsonpCallback(json) {
        console.log(json);
    }

the response from server {"response":{"code":200,"token":"46847c41ed62ee72c8de61ad97f7db6343d5e049"}}

您所请求的API似乎不支持JSONP,请尝试JSON。

您的响应应该是localJsonpCallback({"response":{"code":200,"token":"46847c41ed62ee72c8de61ad97f7db6343d5e049"}}) ,而localJsonpCallback是您的代码中定义的函数

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