Hello,
I’m trying to figure out how to parse through returned data from the jQuery get function. For example, let’s say I have a file called data.html. This file contains this:
[CODE]<div id=”div1″>
<p>Div 1 content</div>
</div>
<div id=”div2″>
<p>Div 2 content</div>
</div>
<div id=”div3″>
<p>Div 3 content</div>
</div>
I then use jQuery AJAX to get that html like this:
[CODE]$.get(‘data.html’, function(data){
var returnedData = data;
$(‘#results’).html(returnedData);
});
This would inject the returned HTML into a div with ID results. That’s all fine and dandy, however I need to target the 3 divs, and place them in different places. For example:
[CODE]$.get(‘data.html’, function(data){
var returnedData = data;
var divOne = $(‘#div1’, returnedData).html();
var divTwo = $(‘#div2’, returnedData).html();
var divThree = $(‘#div3’, returnedData).html();
… do something else with the HTML of each of those Divs.
});
That obviously doesn’t work because the “data” is returning a string (i think?). Is it possible to convert the data into some type of object where I can use the jQuery targeting?
Thanks for any advice!