Jquery - WebService issue
Hi Guys and Gals
Im having some problems consuming a webservice.
The webservice works fine. I can access it and get a response.
However when i attempt to use it though the Jquery & Ajax it always returns and error. its probably something really small but as im faily new to this I cant see it.
Any help or suggestions would be great. Thanks in advance.
JQ & Ajax
-
$("#ddlAggregator").change(function()
{
$.ajax({
async: true,
type: "POST",
url: "(servicename).asmx/methodname",
data: "{aggid:'1'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(response)
{
alert("asda");
}
});
});
WebService
-
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService()]
public class dropListPopulate : System.Web.Services.WebService
{
public dropListPopulate()
{
}
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public ResponseType methodname(string aggid)
{
ResponseType resp = new ResponseType();
//Some MySQL Query here
MySqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
resp.text.Add(reader["Brand"].ToString());
resp.val.Add(int.Parse(reader["BrandID"].ToString()));
}
return resp;
}
}
public class ResponseType
{
public List<string> text = new List<string>();
public List<int> val = new List<int>();
public bool isValid = false;
}