AJAX POST请求在POSTMAN中工作但在Chrome中没有

编程入门 行业动态 更新时间:2024-10-24 18:20:45
本文介绍了AJAX POST请求在POSTMAN中工作但在Chrome中没有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试制作一个简单的AJAX POST请求。在POSTMAN中执行此请求的工作正常。但是,当我在jQuery中编写代码并尝试发出相同的请求时,我得到了

I am trying to make a simple AJAX POST request. This request when executed in POSTMAN works fine. However, when I code it in jQuery and try to make the same request, I get

没有'Access-Control-Allow-Origin'标题出现在请求的资源。因此不允许Origin'file://'访问。响应有HTTP状态代码415.

现在,我必须发出POST请求,因此在请求中使用JSONP作为类型将无济于事。我无权访问服务器代码来修改它。我的基本理解是,如果POSTMAN可以执行它,那么我也应该能够执行它

Now, I have to make a POST request and hence using JSONP as type in the request won't help. I do not have access to server code to modify it. My basic understanding is that if POSTMAN can execute it, then i should be able to do it as well

推荐答案

状态代码是自我解释。 415 当您发送不受支持的内容类型(例如xml)时,它会从服务器返回。仔细检查您在代码中传递给post请求的数据类型。

the status code is self explanatory. 415 it's returned from the server when you sent an unsupported content type (e.g. an xml). double check the type of data you're passing to the post request in your code.

415不支持的媒体类型原始服务器拒绝为请求提供服务,因为有效负载的格式不受此支持目标资源上的方法。

415 UNSUPPORTED MEDIA TYPE The origin server is refusing to service the request because the payload is in a format not supported by this method on the target resource.

格式问题可能是由于请求指示 Content-Type或Content-Encoding,或者是直接检查数据的结果。

The format problem might be due to the request's indicated Content-Type or Content-Encoding, or as a result of inspecting the data directly.

developer.mozilla/en-US/docs/Web/HTTP/Status/415

更多推荐

AJAX POST请求在POSTMAN中工作但在Chrome中没有

本文发布于:2023-10-29 07:54:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1539142.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:但在   工作   POST   AJAX   Chrome

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!