开发者

view xml data in jquery

how do i display xml data using jquery? i don't need to parse it i just need to display it to the user on the page.

Here's my current code:

$.ajax({
    type: "POST",
    dataType: "xml",
    contentType: "application/json; charset=utf-8",
    url: "Service2.svc/DoWork",
    data: "{}",
    processdata: true,
    success: function(response, textStatus, jqXHR) {
        alert($(jqXHR).responseXML);
    }); $("#Text1").val($(response));
}, error: function() {
    alert("error");
开发者_运维百科}
});


I believe this will work:

$.ajax({
    success: function(response, textStatus, jqXHR) {
        alert(jqXHR.xml);
    }
});


I think you'll need to parse it anyways due to the < and > . Use the 'load' method.


I'm assuming you've stored the response XML into the variable xml.

I think this should work:

alert($('<div>').append($(xml).clone()).remove().html());

Credit goes here: How do you convert a jQuery object into a string?


You can just use result.responseText where result is the object returned in your complete function

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜