Home > Web Front-end > JS Tutorial > body text

Detailed introduction to AJAX cross-domain requests

零下一度
Release: 2017-07-20 13:14:03
Original
1365 people have browsed it

Due to the browser's same-origin policy ajax request cannot receive the data returned from the request response

The request data needs to call the browser's built-in constructor XMLHttpRequest() to obtain the instance object

var xhr = new XMLHttpRequest();

Pay attention to the ActiveXobject ("Microsoft. The object is acquired

The four states of obtaining data xhr.readyState This attribute saves the several states of request data

1.xhr.open (request method, request address, settings are the same as / Asynchronous);

  2.

# 4. Data is returned. Then the value of xhr.readyState is 4, indicating that the data is returned successfully.

So we need to make a cross-domain request, how to do it

Option 1:

Use the src attribute of the script tag to request data. The data requested by the src attribute will not be intercepted by the browser

 
Popular Tutorials
More>
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!