[英]POST request works in POSTMAN but not in my code JS
I tried my post request in POSTMAN everything working fine. 我在POSTMAN中尝试了发帖请求,一切正常。 When I pasted the code as Ajax or XRH from POSTMAN, I've got an error message : 当我从POSTMAN中将代码粘贴为Ajax或XRH时,出现了错误消息:
- net::ERR_ABORTED 405 (Method Not Allowed) from chrome or firefox
I am working as localhost from home : can it be a privileges access issue and I don't have enough rights to POST as localhost ? 我正在在家中以localhost的身份工作:这是否是特权访问问题,而我没有足够的权限以localhost身份进行POST?
here is my post request : 这是我的要求:
var data = new FormData(); data.append("file", file); data.append("backup_date", date); data.append("backed_up_device_name", device); var settings = { "async": true, "crossDomain": true, "url": "url", "method": "POST", "dataType": "jsonp", "headers": { "Content-Type": "application/x-www-form-urlencoded", "cache-control": "no-cache", }, "processData": false, "contentType": false, "mimeType": "multipart/form-data", "data": data } $.ajax(settings).done(function (response) { console.log(response); });
Thanks for your answers 谢谢你的回答
The server MUST generate an Allow header field in a 405 response containing a list of the target resource's currently supported methods. 服务器必须在405响应中生成允许标头字段,其中包含目标资源当前支持的方法的列表。
For further information, see the doc 有关更多信息,请参阅文档
That is to say, the POST request to url
is not acceptable by your server. 也就是说,您的服务器不接受对url
的POST请求。 Try looking at this carefully: 尝试仔细看一下:
"url": "url", // what is the url? `"url":"ServerURL"`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.