[英]Using Jquery to call an ASMX service in sharepoint 2010
The service I'm trying to call is deployed as part of a visual web part. 我尝试调用的服务已部署为可视化Web部件的一部分。 If i call it directly: _layouts/service.asmx I get the expected service page, showing me the functions I want to call.
如果我直接调用它:_layouts / service.asmx我得到了预期的服务页面,向我显示了我要调用的功能。 When I do the Jquery Ajax call (it works just fine on my development server) I get a 500 error back from the server.
当我执行Jquery Ajax调用时(在我的开发服务器上正常工作),我从服务器返回了500错误。
$.ajax({
url: 'http://myserver/_layouts/service.asmx/GetLinksToAllFav',
data: "{'tag': '" + $('#MyTag').val() + "', 'TagMaxLength': '" + $('#TagMaxLength').val() + "'}",
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
$('#MyFav').html(data.d);
$('#MyFav').show(100);
},
error: function (all, textStatus, errorThrown) { console.log(textStatus); console.log(errorThrown); }
});
Response HTTP/1.1 500 Internal Server Error 响应HTTP / 1.1 500内部服务器错误
To get this to work I had to add the following to the web.config file. 为了使其正常工作,我必须将以下内容添加到web.config文件中。
<system.web>
<webServices>
<protocols>
<add name="HttpGet" />
<add name="HttpPost" />
</protocols>
</webServices>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.