[英]How to return xml data to jquery ajax call from webservice
This is my ajax call to webservice -JsonWebService.asmx file 这是我对webservice -JsonWebService.asmx文件的ajax调用
$.ajax({
type: "POST",
async: false,
url: "/blkseek2/JsonWebService.asmx/GetList",
data: keyword2,
contentType: "application/xml; charset=utf-8",
success: ajaxCallSucceed,
dataType: "xml",
failure: ajaxCallFailed
});
This is my method for success ,how will i capture xml response in success method 这是我成功的方法,我将如何捕获成功方法中的xml响应
function ajaxCallSucceed(response) {
alert(response.d);
/// here i need to write code to capture response xml doc file
}
This is my code written in webservice jsonwebservice.asmx.cs file,I am able create xml sucess fully but i am finding difficulty in returning xml back to ajax call 这是我写在webservice jsonwebservice.asmx.cs文件中的代码,我能够完全创建xml成功,但是我发现很难将xml返回到ajax调用
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public XmlDocument GetList(string keyword1, string streetname, string lat, string lng, string radius)
{
XmlDocument xmldoc= CreateXML( keyword1,streetname,lat,lng,radius);
return xmldoc;
}
Change your web method as below and try again: 如下更改您的网络方法,然后重试:
[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;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.