I am a .net developer willing to learn mobile web technology. currently i am working on Android platform. I found Jquery to be suitable framework for me as i am from web background. Till now i am able to create a simple web application on android but, i am not able to make AJAX calls from Jquery to my .net webservice. I want to create a test enviornment for my android web app.
1. I have ASP.NET web service running on my local computer
namespace JqueryMobile
{
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
}
}
my webservice URL is : http://localhost:26415/WebService1.asmx
2. My android index.html
$(function(){
$.ajax({url:"localhost:26415/WebService1.asmx/HelloWorld",
success:function(result){
alert(result);
}});
});
This technique fails in local environment so, how do i test it?
make these changes:
1.uncomment
[System.Web.Script.Services.ScriptService]as an attribute to your Web Method2.Also change your url to like http://localhost:1096/MySite/WebService.asmx/HelloWorld?callback
3.try using IP address instead of loaclhost http://IPADDRESS:1096/MySite/WebService.asmx/HelloWorld?callback
see this post:What is the best way to call a .net webservice using jquery?