Get json data across domains with ajax

This afternoon's pit was finally resolved.

Get json data across domains with ajax

  1. When the requested content is json data, it is not feasible to use jsonp to obtain cross-domain data, and "Uncaught SyntaxError: Unexpected token:" will be displayed.
  2. Since the server cannot be changed, the same-origin policy cannot be added to allow the header, it can only be operated in the browser, and
    the API conversion mechanism of eezzo.com can be used successfully. The example is as follows:
var requestUrl = "https://news-at.zhihu.com/api/4/news/latest";
        //这里一定要注意,实际请求的url其实是以参数形式从eezzo.com读取的,因此我们都要对url进行编码,使用encodeURI方法即可
        $.getJSON("http://eezzo.com/API/CD", { url: encodeURI(requestUrl) }, function(json) {
            console.log(json);
        });

Acquired data:
obtained data

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325169412&siteId=291194637