【发布时间】:2012-12-12 15:38:31
【问题描述】:
我是 Web 服务的新手,当我尝试在 Chrome 控制台中运行我的页面(本地)时遇到以下错误
错误
加载资源失败:服务器响应状态为 405 (Method Not Allowed)
http://localhost:12015/myWebService.asmx?op=GetCategories
相关代码如下:
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");
}
网络服务网址
http://localhost:12015/myWebService.asmx
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Categories> GetCategories()
{
//code
}
页面网址
http://localhost:11761/Default.aspx
编辑:当我刚刚包含 dataType: 'jsonp' 时,错误消失了,但现在又出现了另一个错误。
Uncaught SyntaxError: Unexpected token
:12015/myWebService.asmx?op=GetCategories&callback=jQuery183010907560377381742_1356599550427&{}&_=1356599550438:3
当我点击链接(在错误中提到)时,它正在显示页面。那么可能是什么问题?我不知道错误的含义(以及要显示的代码部分)。请帮忙。
相关
【问题讨论】:
-
@mdcuesta 是的,对不起,我忘了说一切都是本地的(我的意思是在我的电脑上)
-
你的
dataType='jsonp'是吗? -
看起来你是在做 GET 而不是 POST
-
你可以看看这个:checkupdown.com/status/E405.html
标签: jquery asp.net web-services