我是新来的web服务。在我的项目中,当我试图运行时,我连接了Web Service(一切都已准备就绪),我得到了下面的错误。未捕获的SyntaxError:意外的令牌< - 在jQuery中ajax
错误 - >
Uncaught SyntaxError: Unexpected token <
的Web服务和我的网页是在同一个解决方案,但不同的项目。
相关的代码如下:
jQuery的(网址:11761)
function GetAllCategories() {
$.ajax({
url: "http://localhost:12015/myWebService.asmx?op=GetCategories",
type: "POST",
dataType: "jsonp",
data: "{}",
contentType: "application/jsonp; charset=utf-8",
success: function (data) {
var categories = data.d;
$.each(categories, function (index, category) {
alert(category.CategoryId);
});
},
error: function (e) {
alert(e.message);
}
});
}
Web服务(网址:12015)
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<Categories> GetCategories()
{
//Code
}
之前问我在这里已经通过这link(不能理解它)
编辑:
得到备选答案从这个post。
确保您最后没有'<'标签。 – Blender
@Blender不存在..没有代码错误的权利? –
何时发生此错误(在您的AJAX调用或脚本加载后)? – Blender