Detailed explanation of the steps to receive josn data using josnp in ajax

php中世界最好的语言
Release: 2018-03-30 16:43:27
Original
1791 people have browsed it

This time I will give you a detailed explanation of the steps for using josnp to receive josn data in ajax. What are theprecautionsfor using josnp to receive josn data in ajax. The following is a practical case, let's take a look.

Recently, I encountered a problem when checking theExpressweb page. Theapiof Express 100 was called, but the Express 100 api did not allow cross-domain requests, so 127.0 was used. Requests sent by 0.1 will be intercepted directly.

It’s just a simple web page. I don’t want to do the server forwarding myself, so I finally found ajsonp proxy provided by yahoo:

http://query.yahooapis.com /v1/public/yql

var queryUrl = "\"http://www.kuaidi100.com/query?type=" + $("#type").val() + "&postid=" + $("#postid").val() + "\""; $.ajax({ url: 'http://query.yahooapis.com/v1/public/yql', //jsonp代理api dataType: "jsonp", data: { q: "select * from json where url=" + queryUrl, format: "json" }, success: function(result) { var res = result.query.results.json; console.log(res); } }, }) });
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

ajax combined with mysql database to achieve partial data refresh

Security performance of Web and AJAX

The above is the detailed content of Detailed explanation of the steps to receive josn data using josnp in ajax. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!