This article introduces a JSONP cross-origin access proxy API-yahooapis. If you need a friend, you can refer to whether you want to use AJAX to access some public network APIs, but you do not want to create your own proxy service, sometimes I don't plan to involve any code on the server, but the annoying browser's same-origin policy blocks ajax calls.
For example, if I want to access a weather restfull api, If I directly go to GET:
The Code is as follows:
$. Get ("http://m.weather.com.cn/data/101010100.html ");
I believe everyone will be familiar with this problem and will naturally get a solution. But I really don't want to touch any server code here. Use jsonp, but the server has not implemented the contract.
Here I am introducing the jsonp agent from the main character yahoo: http://query.yahooapis.com/v1/public/yql
Implementing cross-origin access code: http://jsfiddle.net/whitewolf/4UDpf/9/
Html:
The Code is as follows: