在SharePoint 2010中使用Jquery调用ASMX服务 [英] Using Jquery to call an ASMX service in sharepoint 2010

查看:70
本文介绍了在SharePoint 2010中使用Jquery调用ASMX服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要调用的服务已部署为可视化Web部件的一部分.如果我直接调用它: _layouts/service.asmx 我得到了预期的服务页面,其中显示了我要调用的功能. 当我执行Jquery Ajax调用时(在我的开发服务器上运行正常),我从服务器返回了500错误.

The service I'm trying to call is deployed as part of a visual web part. If i call it directly: _layouts/service.asmx I get the expected service page, showing me the functions I want to call. When I do the Jquery Ajax call (it works just fine on my development server) I get a 500 error back from the server.

$.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); }
});

响应HTTP/1.1 500内部服务器错误

Response HTTP/1.1 500 Internal Server Error

推荐答案

要使其正常工作,我必须将以下内容添加到web.config文件中.

To get this to work I had to add the following to the web.config file.

  <system.web>
    <webServices>
      <protocols>
        <add name="HttpGet" />
        <add name="HttpPost" />
      </protocols>
    </webServices>

这篇关于在SharePoint 2010中使用Jquery调用ASMX服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆