Home  >  Article  >  Web Front-end  >  What is cross-domain access? From both front-end and back-end perspectives

What is cross-domain access? From both front-end and back-end perspectives

云罗郡主
云罗郡主Original
2018-10-18 11:48:598361browse

Many people don’t know what cross-domain access is? What is cross-domain access? Let's talk about cross-domain access for you from both front-end and back-end perspectives.

timg (1).gif

1: Front-end tells what cross-domain access is

1. What is cross-domain access? What is cross-domain access?

Before understanding what cross-domain access is, let’s first use a case to describe cross-domain access. If I have a website a, I now want to get some content on website b through Ajax, a and b. In different domains, a cross-domain problem will arise at this time. In fact, the two domain names cannot be simply requested through the domain name, and the same-origin policy stipulates that the browser can only access HTML. Page resources.

2.What is JSONP? Introduction to JSONP

JSONP is actually another usage mode of JSON. Under normal circumstances, we use JSONP to solve the problem of cross-domain access.

For the same-origin policy, if you encounter two websites with different domain names, you cannot communicate, but there is an exception for the elements in the website's html. Web pages can generate JSON from other sources, but what JSONP captures is not JSON.

2: The backend details what cross-domain access is

Cross-domain access requires the server to do two things. The first thing is to accept the verification parameters and cooperate with The front-end sets the parameters to accept the parameters. The second step is to construct the received parameters and the actual data.

The above is the explanation of what is cross-domain access? A complete introduction from both the front-end and back-end perspectives. If you want to know more about HTML video tutorial, please pay attention to the PHP Chinese website.


The above is the detailed content of What is cross-domain access? From both front-end and back-end perspectives. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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