Failed to load http://example.com/stack/api/order_food: Response for preflight has invalid HTTP status code 405.
我在论坛上发现了很多帖子,但不幸的是,没有什么对我有用。我在我的索引.html
<meta http-equiv="Content-Security-Policy" content="default-src *;
img-src * 'self' data: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' *;
style-src 'self' 'unsafe-inline' *">
$.ajax({
"url": "http://example.com/stack/api/order_food",
"type": "POST",
"headers": {
"cache-control": "no-cache",
},
"processData": false,
"contentType": false,
"data": form,
success: function (resultData) {
if(!resultData)
{
alert("Failed to get result data");
return;
}
var res = JSON.parse(resultData);
if(res.status == "success")
{
alert("Success");
}
else
{
alert("Failed");
}
},
error: function (err) {
console.log(err);
}
});