0

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?

3
  • Use CDATA, otherwise you won't be able to handle XML inside your document. Commented May 11, 2012 at 14:21
  • I think it won't be that simple, even if you set the datatype to text I think you probably still need to properly format certain characters such as < and > character. Commented May 11, 2012 at 14:38
  • @RosdiKasim jquerys text method would handle that. Commented May 11, 2012 at 14:40

2 Answers 2

1

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);
Sign up to request clarification or add additional context in comments.

2 Comments

still outputs [object Document]
@AndyJacobs try jqXHR.responseText I did not have the possibility to test this, so I wasn't too sure which one was the right one.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.