该服务器的405状态响应(不允许的方法) [英] the server responded with a status of 405 (Method Not Allowed)
问题描述
我是新来的Web服务队,我收到以下错误,当我试图运行我的网页(本地)在Chrome控制台
错误
无法加载资源:服务器与405状态响应(不允许的方法)
的http://本地主机:12015 / myWebService.asmx OP = GetCategories
块引用>下面是相关的code:
的的jQuery 的
$阿贾克斯({
网址:HTTP://本地主机:12015 / myWebService.asmx OP = GetCategories
键入:POST,
------------
------------
成功:功能(数据){
VAR类别= data.d;
$。每个(类别,功能(指数类){
category.CategoryId)的.text(category.CategoryName);
});
},
错误:功能(E){//始终执行错误只
警报(你好);
}的 Web服务URL 的
的http://本地主机:12015 / myWebService.asmx
块引用>[的WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)
公开名单<类别> GetCategories()
{
// code
}的页网址的
的http://本地主机:11761 / Default.aspx的
块引用>编辑:错误不见了,当我刚刚列入
数据类型:'JSONP
但现在有另一个错误
未捕获的SyntaxError:意外的令牌LT;结果
<$c$c>:12015/myWebService.asmx?op=GetCategories&callback=jQuery183010907560377381742_1356599550427&{}&_=1356599550438:3$c$c>
块引用>当我点击(这是在错误中提到)的链接,它显示的页面。那么可能是什么问题呢?我不知道错误是什么意思(也code的一部分,显示哪个)。请帮助。
相关
解决方案我添加了jQuery ajax调用我上面的朋友的建议下一个简单的行
jQuery.support.cors = TRUE;
现在它是工作的罚款:)
只能出现在 IE 浏览器
我会很高兴地知道它是否可以采用不同的方式,因为它是不推荐来解决。
不管怎样,我再次问到这个问题,经过多次努力,我这是在这篇文章中解决了不同的错误 这里
I am new to Web Sevice, I am getting the following error when I tried to run my page (Local) in Chrome Console
ERROR
Failed to load resource: the server responded with a status of 405 (Method Not Allowed)
http://localhost:12015/myWebService.asmx?op=GetCategories
Here is the related code:
jQuery
$.ajax({ url: "http://localhost:12015/myWebService.asmx?op=GetCategories", type: "POST", ------------ ------------ success: function (data) { var categories = data.d; $.each(categories, function (index, category) { category.CategoryId).text(category.CategoryName); }); }, error: function (e) { //always executing 'error' only alert("hello"); }
web service URL
http://localhost:12015/myWebService.asmx
[WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public List<Categories> GetCategories() { //code }
Page URL
http://localhost:11761/Default.aspx
EDIT: The error gone when I just included
dataType: 'jsonp'
But now there is another error.Uncaught SyntaxError: Unexpected token <
:12015/myWebService.asmx?op=GetCategories&callback=jQuery183010907560377381742_1356599550427&{}&_=1356599550438:3
When I clicked the link(which was mentioned in the error), it is displaying the page. Then what could be the problem ? I dont know what the error means (and also which part of code to show). Please help.
Related
Link1 (explanation)
Link2 (solved)解决方案I added a simple line on my friend's suggestion above the jquery ajax call
jQuery.support.cors = true;
Now it is working fine :)
ONLY IN IE BROWSER
I would be happy to know if it can be solved using different way as it is not recommended.
Anyhow I asked this question again after many efforts and I got different error which was solved in this post here
这篇关于该服务器的405状态响应(不允许的方法)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!