【发布时间】:2013-08-03 20:29:01
【问题描述】:
我在调用跨域 Web 服务时遇到问题。我在这里阅读了一些关于它的文章,但我并没有真正找到解决方案。我刚刚明白我需要json 格式的数据,因为我在尝试从服务中获取xml 数据时总是得到Error: Access denied.,但现在我遇到了不同的问题。这是我的.ajax() 电话:
$.ajax({
type: "GET",
contentType: "application/jsonp; charset=utf-8",
url: "http://tomas/_vti_bin/EmmaService.asmx/GetResult",
dataType: "jsonp",
data: {
value : "testValue",
converstionId : "testId"
},
success: function(resp) {
alert("success: " + resp);
},
error: function (xhr, ajaxOptions, thrownError) {
alert("error status: " + xhr.status);
alert("error status text: " + xhr.statusText);
alert("error response text: " + xhr.responseText);
},
});
由此我收到以下 3 个警报错误:
error status: 200
error status text: success
error response text: undefined
我不明白的是error status text: success。
我的网络服务中的代码:
[WebMethod(EnableSession = false, Description = "Gets result")]
public EmmaServiceResult GetResult(string value, string converstionId)
{
...
return result;
}
关于如何使它工作的任何建议?谢谢! :)
【问题讨论】:
-
注意:我无法更改 Web 服务,它正在被其他解决方案使用,我需要正确调用它并在没有任何代码的情况下工作,只需 javascript,因为我正在创建一个 SharePoint 2013 应用程序,它不允许隐藏代码:/
-
您能否在 Firefox 和/或 Chrome Web Inspector 上的 Firebug 中运行此程序,然后将整个请求(文本)和响应(同上)剪切并粘贴到问题中?
-
检查浏览器开发工具中的 javascript 控制台和网络选项卡。查找任何错误,并查看 xhr 响应,看看它是否符合您的预期。
-
我收到
Uncaught TypeError: Object [object Object] has no method 'autocomplete'
标签: javascript jquery ajax json web-services