Load data from external jQuery file
I need to take data from an external file and format it, the problem is, I want this data to be stored in a variable. The upload method works for me because I don't need to upload the whole document, but only a part of it, but again, I want to upload a variable, not any dom element. $ .get can do this, but does not support selectors. Can I do it? Now the examples: An external file Mine consists of a table that has the following format:
<table><tr><td><img /></td></tr><tr><td><a></a></td><td><span></span></td></tr></table>
I need to extract the img, a and span tags because I need them to appear in a different order than they are now. So, do I have a chance that I can make this work? Thanks.
a source to share
You have to execute a get query and set the result type to XML and then use jquery selectors to find information in the data.
examples here: http://www.switchonthecode.com/tutorials/xml-parsing-with-jquery
a source to share
EDIT: I haven't looked closely enough at naugtur's answer . In essence, he spoke.
Should work $.get()
. Not sure what you mean when you say it doesn't support selectors. You can use a callback and work with the returned data.
$.get('/path/to/data', function(data) {
// returned value is stored in 'data' variable
// You can manipulate it, and append where you want
$myImage = $('img', data);
$myImage.appendTo('body');
});
a source to share