$.getJSON parsererror trying to call API

☆樱花仙子☆ 提交于 2019-12-02 07:34:44

Your parameter will not simply "guess" what the [URL] param is. Try this:

var clippedAPI = "http://clipped.me/algorithm/clippedapi.php";
$.ajax({
url: clippedAPI,
type: "GET",
dataType: "JSONP",
data: {
url: "http://pandodaily.com/2013/03/26/y-combinator-demo-day-2013-still-looking-for- the-next-airbnb-or-dropbox/"}
}).done(function(json) {
        console.log("JSON Data: " + json.title );
}).fail(function(jqxhr, textStatus, error){
        var err = textStatus + ', ' + error;
        console.log("Request Failed: " + err);
});

Even this fails, however, as your API endpoint does not seem to understand/support JSONP and does not provide a Access-Control-Allow-Origin header. You therefore have two choices:

  • You can reverse-proxy the API locally to get around the cross-domain issue and go through standard JSON
  • You can...ehm... get a better API? Lodge a ticket with the devs to get it sorted.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!