I am trying to call asp.net webmethod from xmlhttp object.
My webmethod is like this
[WebMethod]
public string getCities(string province)
And my javascript is like following
xmlhttp=new XMLHttpRequest({mozSystem: true});
xmlhttp.open("POST","http://www.rental-1.com/lp.aspx/getCities/Ontario",true);
xmlhttp.send();
xmlhttp.onreadystatechange=function(){
alert(xmlhttp.readyState+", "+xmlhttp.status);
if (xmlhttp.readyState==4 && xmlhttp.status==200){
var v1=xmlhttp.responseText;
alert(v1);
}}
In response I am getting the whole html of the page. But above I am calling just webmethod and I expecting string value in return.
Any help will be appreciated. Why I am not getting just string value instead of html of the page
here is my server side code
[WebMethod]
public static List<string> getCities(string province)
{
List<string> strp = new List<string>();
strp=getCitiesFromDB(province);
return strp;
}