Home  >  Article  >  Backend Development  >  How to set up cross domain in php

How to set up cross domain in php

hzc
hzcOriginal
2020-06-10 16:31:423786browse

How to set up cross domain in php

Let’s first write an example without cross-domain:

$(document).ready(function(){
   $.ajax({
       type : "POST",
       url : "http://localhost/test8.php",
   });
});

Successfully responded to the message.

How to set up cross domain in php

How to set up cross domain in php

We write a special cross-domain example and change the domain name to 127.0.0.1:

$(document).ready(function(){
   $.ajax({
       type : "POST",
       url : "http://127.0.0.1/test8.php",
   });
});

Discover Cross-domain.

How to set up cross domain in php

How to set up cross domain in php

##We modify test8.php:

//允许所有地址跨域请求
header("Access-Control-Allow-Origin: *");

How to set up cross domain in php

How to set up cross domain in php

How to set up cross domain in php

Recommended tutorial: "

php tutorial"

The above is the detailed content of How to set up cross domain in php. 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