Problems of interface data interaction in projects with different domain names

Source: Internet
Author: User
Keywords Php
There are two different domains, the first item in the domain click on a button and then invoke the project interface in the second domain name, and then implement the logic function in the project of the second domain name, I want to ask the big gods how to return the project data in the second domain name to the first domain name call function.

Reply content:

There are two different domains, the first item in the domain click on a button and then invoke the project interface in the second domain name, and then implement the logic function in the project of the second domain name, I want to ask the big gods how to return the project data in the second domain name to the first domain name call function.

This is a cross-domain Baidu you will know

With JSONP

Back end, it is called by the second domain to provide a similar restful API through HTTP,
If you must have a front-end call, which solves the cross-domain problem first, Ajax is your best choice, if there is a cross-domain problem, there are josnp optional

If the interface is called for a Web page, you can use JSONP, but only for get requests. You can also use Ajax, to solve cross-domain, need to add Origin header.

Jsonp or Ajax+header ("access-control-allow-origin:*");

  • Related Article

    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.