I'm using ASP.net and I'm trying to execute a webmethod from jquery. I have the following file structure:
/MyWebService.asmx
/MyPage1.aspx (referencing a javascript file which calls a webmethod in MyWebService.asmx)
/MySubFolder/MyPage2.aspx (MyPage2.aspx referencing the same javascript file)
My problem is that MyPage1.aspx can call the webmethod in the web service but MyPage2.aspx can't. Any ideas why? It has to be related to the fact that MyPage2.aspx is in a subfolder. If I simply move MyPage2.aspx to the root it works.
I'm using jquery and the code in the javascript file looks like this:
$.ajax({
type: "POST",
url: "MyWebService.asmx/MyWebMethod",
data: "{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg)
etc.
I've tried changing the url to: /MyWebService.asmx/MyWebMethod (with a slash in front of MyWebService) but it doesn't make any difference.
Thanks.