Ajax Post Laravel 共享主机上的 403 错误
403 error on Ajax Post Laravel shared hosting
网站在其他主机上运行完全正常。那也是共享的。但在发出 Ajax post 请求时不适用于当前主机。服务器(不是应用程序)以 403 响应。
我现在该怎么办?我使用了 postman,它工作正常。 url 也没有问题。
更新:
ajax 请求的代码:
$.ajax({
type: "POST",
url: window.location.href.split('?')[0],
data: data,
success: function(data){
window.location = data.redirect_to;
},
error: function(data){
},
dataType: 'json'
});
问题是 "not setting" content-type headers。
我把代码改成了:
$.ajax({
type: "POST",
url: window.location.href.split('?')[0],
data: JSON.stringify(data),
success: function(data){
window.location = data.redirect_to;
},
error: function(data){
},
dataType: 'json',
headers: {
'Content-Type':'application/json'
}
});
成功了。
网站在其他主机上运行完全正常。那也是共享的。但在发出 Ajax post 请求时不适用于当前主机。服务器(不是应用程序)以 403 响应。
我现在该怎么办?我使用了 postman,它工作正常。 url 也没有问题。
更新: ajax 请求的代码:
$.ajax({
type: "POST",
url: window.location.href.split('?')[0],
data: data,
success: function(data){
window.location = data.redirect_to;
},
error: function(data){
},
dataType: 'json'
});
问题是 "not setting" content-type headers。 我把代码改成了:
$.ajax({
type: "POST",
url: window.location.href.split('?')[0],
data: JSON.stringify(data),
success: function(data){
window.location = data.redirect_to;
},
error: function(data){
},
dataType: 'json',
headers: {
'Content-Type':'application/json'
}
});
成功了。