简体   繁体   中英

how to display a full XML in an html page with jquery

I load an xml

        $.ajax({
            url: '../rest/',
            dataType: "xml",
            success: showXML

        });

        function showXML(xml) {
            $("#output").text((xml));   
        }

but he doesn't show the xml in my output div

he shows this: [object Document] what needs to be done so he will simple display the xml?

Because you set the dataType to xml jquery will automatically give you an object for the data-parameter of your success callback.

Try using this signature:

function showXML(xml, textStatus, jqXHR)

and:

$("#output").text(jqXHR.responseText);

Change the dataType to "html" or "text" . If that doesn't work, you may need to do what was said in the comment to your post.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM