开发者

JQuery Ajax web method link to test domain not working

I have a webmethod in my solution which is called using Jquery Ajax method. This works great in my development solution. BUt does not work when uploading to my test domain When I upload the solution to the test domain:

wwww."".com/test/

It can't seem to access my method. I looked into the problem using firebug and it looks like its looking for:

    www."".com/webservices/service

Because I am using the test environment it should change to find the webservices folder, like so:

www."".com/test/webservices/service

script:开发者_StackOverflow

<script type="text/javascript">

 function GetData() {     

    $.ajax({
        type: "POST",
        url: "../../WebServices/Service.asmx/GetData",
        data: JSON.stringify({

        }),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(msg) {

        },
        error: function(xhr, ajaxOptions, thrownError)
        { alert(ajaxOptions); }
    });
   }  

   </script>

my c# is:

  [System.Web.Services.WebMethod()]
        public string GetData()
    {

    }  

Does anyone have any ideas as to how I can solve this problem?

Cheers


Try like this:

url: '<%= ResolveUrl("~/WebServices/Service.asmx/GetData") %>'


Just remove one of the ../:

url: "../WebServices/Service.asmx/GetData",
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜