Jsonp principle Finishing

Source: Internet
Author: User
Tags script tag

Website A (a.com) needs to obtain the relevant data of website B (B.Com)

The basic principle: the website can obtain different domain website's js, the picture and so on content, therefore JSONP can request the concrete step only through GET requests: 1, in the website a new window function, such as Window.dealcallbanck () 2, Create a new url:b.com/arg?arg1=xxx&arg2=xxx on site B to return the data required for site A 3, in Site A, use JS to create a new script tag, and then set src=b.com/arg?arg1=xxx  &ARG2=XXX4, can see B.com/arg returned data is Dealcallbanck (ARG1,ARG2) 5, because the returned content is in a JS, so you can directly trigger the Dealcallbanck event Of course, you can also use jquery more easily

Jsonp principle Finishing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.