Skip to content
This repository has been archived by the owner on Apr 16, 2019. It is now read-only.

Importing of XML via ajax call doesn't work #19

Closed
premghinde opened this issue Jan 19, 2012 · 5 comments
Closed

Importing of XML via ajax call doesn't work #19

premghinde opened this issue Jan 19, 2012 · 5 comments

Comments

@premghinde
Copy link

$(function(){
$.ajax({
url: 'http://api.jquery.com/api/',
dataType: 'xml',
success: function(x){
console.log($(x).find('entry'));
}
});
});

My guess is that 'x' is treated as a string and not passed into the success callback as XML.

@premghinde
Copy link
Author

Apologies, I completely forgot to pass the response through the parseXML function I'd created. :(

@imaffett
Copy link
Contributor

I get a cross domain issue when I try to test this. Are you running the XML locally?

@imaffett
Copy link
Contributor

Haha...no problem, is it ok if I close this?

@premghinde
Copy link
Author

Yes, sorry, I've pulled down a local copy of the file.

Is it worth adding the parse function into the library? It's a simple one.

function parseXml(xmlStr) {
return ( new window.DOMParser() ).parseFromString(xmlStr, "text/xml");
}

@imaffett
Copy link
Contributor

We will consider this for the 1.0 release. I'm guessing you want it to automatically parse text/xml repsonses too ;)

Thanks for the code snippet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants