Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have jquery ajax call to webservice for which i am passing xml parameters as data ,when i run the code the flow is not reaching webservice GetList method at all, can anyone track what may be the problem should i make any changes to my webconfig file or refer any latest jquery file to get the code running sucessfully

$.ajax({
type: "POST",
async: false,
url: "/blkseek2/JsonWebService.asmx/GetList",
datatype:"xml",
data:"<?xml version='1.0'?><keyword1>"+keyword1+ "</keyword1><streetname>"+address1+ "</streetname><lat>"+lat+"</lat><lng>"+lng+ "</lng><radius>"+radius+"</radius>" ,
contentType: "application/xml; charset=utf-8",
// processData: false,
failure: function(XMLHttpRequest, textStatus, errorThrown)
{ ajaxError(XMLHttpRequest,textStatus, errorThrown); },
success: function(xml)
{ ajaxFinish(xml); }
});
});



This will be webmethod on webservice file .


[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Xml)]


public XmlDocument GetList(string keyword1, string streetname, string lat, string lng, string radius)
{
XmlDocument xmldoc= CreateXML( keyword1,streetname,lat,lng,radius);


return xmldoc;

}
Posted

1 solution

I would suggest not to use XML as parameters and return data to invoke web service methods from JavaScript. JSON is much better option for this because it will allow you to send parameters and parse the return data using JavaScript's built in mechanism, in an easy manner.

See http://www.asp.net/ajax/tutorials/understanding-asp-net-ajax-web-services[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900