0

I'm getting an xml answer from a server using jquery and I need to have one of its child nodes as a string to further work with it. Here is my code:

function pollServer(dataObject) {
    $.ajax({
        type: "POST",
        url: '/server.php',
        data: dataObject,
        success: function (data) {
            $xmlDoc = $(data);
            $listen = $xmlDoc.find('listen');
            console.log($listen);
        },
        dataType: 'xml'
    });
}

I already tried using (new XMLSerializer()).serializeToString(listen) but that gives me an empty string.

1 Answer 1

2

The following should work fine for XML:

var listen = $("listen", data)[0].outerHTML;
Sign up to request clarification or add additional context in comments.

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.