开发者

view xml data in jquery

开发者 https://www.devze.com 2023-02-28 00:39 出处:网络
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.

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

精彩评论

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