Ajax请求出现“Method Not Allowed 405”
来源:互联网 发布:无法访问家庭网络共享 编辑:程序博客网 时间:2024/06/06 21:44
问题代码如下:
$.ajax({ url:"HtmlPage1.html", dataType: "html", success: function (html) { $("#fdsf").val(html); }, error: function (html,state) { alert(state); $("#fdsf").val(html); } })
在谷歌浏览器观察下发现网页请求错误:
一直把错误报在了ajax中error中;然后在网站找了一下解决方法;
如下:
Q1: 遇到405请求错误。提示:
NSLocalizedDescription=Request failed: method not allowed (405)。
解决方案:405请求方法不被允许。这时候应该检查请求方法是否正确,页面应该用GET请求还是POST请求。例如在请求微博access_token的时候虽然不需要发送数据但这个页面却要求使用POST请求。
Q2: 使用AFNetwork进行HTTP请求遇到如下提示信息错误:
NSLocalizedDescription=Request failed: unacceptable
content-type: text/plain。
解决方案:这里的错误提示是因为AFHTTPRequestOperationManager默认的http请求头没有包含text/plain格式。应使用
manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject:@”text/plain”];手动添加。当然也可能会出现text/html类型的。解决方案同理手动添加。
最后我给代码添加了 type:”get”,问题解决了。很奇怪一点,type:”get”是默认的,为什么还要添加????
阅读全文
0 0
- Ajax请求出现“Method Not Allowed 405”
- ajax调用servlet出现405 (Method Not Allowed)
- http请求返回405 (Method Not Allowed)
- 405 Method Not Allowed on ajax PUT
- jQuery ajax 请求HttpServlet返回[HTTP/1.1 405 Method not allowed]
- 405 Method Not Allowed
- 405 Method Not Allowed
- 405 (Method Not Allowed)
- 405 Method Not Allowed
- Method Not Allowed 405
- 关于TOMCAT6+COMET出现405 Method Not Allowed错误解决方法
- tomcat6 comet 出现 method not allowed(405)时
- iis 405 Method Not Allowed
- HTTP 405Method not allowed
- webapi 405 method not allowed
- post 405 method not allowed
- 解决“HTTP/1.1 405 Method not allowed”问题,让静态文件响应POST请求
- 解决“HTTP/1.1 405 Method not allowed”问题,让静态文件响应POST请求
- WebView 基础使用
- Mac上使用 sunny- ngrok
- 基于MTK平台kpd 驱动解析
- 内网映射到外网的工具ngrok使用
- 欢迎使用CSDN-markdown编辑器
- Ajax请求出现“Method Not Allowed 405”
- 修复Ubuntu unable access to dev/sdb- 无法挂载Windows下文件夹问题
- 享元模式
- 虚拟ubuntu系统中浏览器的音频播放问题
- 深度学习在美团点评推荐平台排序中的运用
- 暴利截流,各路神仙让我等沾沾仙气
- java Thread的探索(一)
- HDU 4121 Xiangqi
- HDU 6127 Hard challenge