[英]How to return xml data from webservice to jquery ajax call from a webform
[英]How to return xml data to jquery ajax call from webservice
這是我對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
});
這是我成功的方法,我將如何捕獲成功方法中的xml響應
function ajaxCallSucceed(response) {
alert(response.d);
/// here i need to write code to capture response xml doc file
}
這是我寫在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;
}
如下更改您的網絡方法,然后重試:
[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.