我想使用获取请求返回产品数组。该响应返回带有200请求的XML。jQuery的Ajax请求语法错误:意外的令牌<
Web服务:
[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
public List GetAllProducts()
{
using (SchulteDesignYourOwnEntities db = new SchulteDesignYourOwnEntities())
{
return db.products.ToList();
}
}
这里是我的代码:
$(document).ready(function() {
$.ajax({
url: 'http://www.organizeliving.com/designwebservice.asmx/GetAllProducts',
dataType: 'json',
success: function (result) {
alert("Result: " + result.length);
},
error: function (xhr, ajaxOptions, thrownError) {
console.log("Status: " + xhr.status);
console.log("Message: " + thrownError);
}
});
});
+0
检查返回产品列表中的任何字符串属性是否包含“
+0
它的确如此。我的问题似乎是我无法从我的.asmx Web服务返回json。我的回复是Soap/XML。 –