2010-09-02 98 views
1

返回的jQuery AJAX調用這是我的Ajax調用WebService的-JsonWebService.asmx文件如何將XML數據從web服務

$.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 
} 

這是寫在Web服務jsonwebservice.asmx.cs文件我的代碼,我可以創建XML sucess充分,但我在返回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; 

    } 
+0

所以......沒有幫助? – 2010-09-02 06:25:08

回答

5

如下更改Web方法,然後再試一次:

[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; 
}