ajax post request error-PHP Chinese Network Q&A
ajax post request error
匿名
匿名 2019-04-17 15:48:00
0
1
1125

表单结构

function mysubmit(){ var xhr ; if (window.XMLHttpRequest) { // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码 xhr=new XMLHttpRequest(); } else { // IE6, IE5 浏览器执行代码 xhr=new ActiveXObject("Microsoft.XMLHTTP"); } xhr.open("POST","http://localhost/graduationProject/server/login.php",true); xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xhr.send("userid=1111&username=1111&password=1111"); // body... }

ajax请求


浏览器报错:index.html:1 Failed to load http://localhost/graduationProject/server/login.php: Redirect from 'http://localhost/graduationProject/server/login.php' to 'http://localhost/graduationProject/browser/flappybirds/index.html' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

匿名
匿名

reply all (1)
Alone88

Cross-domain problem, php adds header('Access-Control-Allow-Origin:*');


    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!