Using Jquery to call an ASMX service in sharepoint 2010

ⅰ亾dé卋堺 提交于 2019-12-11 17:15:31

问题


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

Response HTTP/1.1 500 Internal Server Error


回答1:


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>


来源:https://stackoverflow.com/questions/9035539/using-jquery-to-call-an-asmx-service-in-sharepoint-2010

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!