Jquery 同源 Ajax 调用错误
Jquery Same Origin Ajax Call Mistake
有问题的站点是 test1。guru99.com
我正在像这样制作 SAME ORIGIN
var myemail = "test@gmail.com";
jQuery.ajax({
type: 'GET', //Define the method type
url:'http://test1.guru99.com/Customization/popup/subscription-list.php',
data: {email: myemail},
success: function(d) {
console.log('success');
},
});
但我收到类似
的错误
您看到此错误是因为 requesting/receiving 个站点的域不同。
您从请求的站点是www.test1.guru99.com
,接收者是test1.guru99.com
。请注意,域的每个部分 都必须 匹配,直至子域和协议。
假设 www.
子域指向同一个地方,我建议您修改 $.ajax
调用以使用相对路径。
发生 CORS 错误是因为您的站点不是“test1.guru99.com”。它是“www.test1.guru99.com”。 (它会自动重定向)
因此,由于您希望脚本 运行 来自同一域,因此只需从中排除该域
jQuery.ajax({
type: 'GET', //Define the method type
url:'/Customization/popup/subscription-list.php',
data: {email: myemail},
success: function(d) {
console.log('success');
}
});
(但不会解决500错误)
有问题的站点是 test1。guru99.com 我正在像这样制作 SAME ORIGIN
var myemail = "test@gmail.com";
jQuery.ajax({
type: 'GET', //Define the method type
url:'http://test1.guru99.com/Customization/popup/subscription-list.php',
data: {email: myemail},
success: function(d) {
console.log('success');
},
});
但我收到类似
的错误您看到此错误是因为 requesting/receiving 个站点的域不同。
您从请求的站点是www.test1.guru99.com
,接收者是test1.guru99.com
。请注意,域的每个部分 都必须 匹配,直至子域和协议。
假设 www.
子域指向同一个地方,我建议您修改 $.ajax
调用以使用相对路径。
发生 CORS 错误是因为您的站点不是“test1.guru99.com”。它是“www.test1.guru99.com”。 (它会自动重定向)
因此,由于您希望脚本 运行 来自同一域,因此只需从中排除该域
jQuery.ajax({
type: 'GET', //Define the method type
url:'/Customization/popup/subscription-list.php',
data: {email: myemail},
success: function(d) {
console.log('success');
}
});
(但不会解决500错误)