I'm wondering what the correct syntax is to traverse the data returned of this function:
$.get(url, function(data){
alert(data);
});
data.find("table") or similar does not work. The returned html data looks like this, parsed from a django template:
<div class="pagination">
<span class="step-links">
<span style="visibility:hidden;">previous</span>
<span class="current">
Page 1 of 2.
</span>
<a id="next" href="?page=2">next</a>
</span>
</div>
<form class="" id="action-selecter" action="" method="POST">
<div class="action_dropdown">
<label>Action: <select name="action">
<option value="" selected="selected">---------</option>
<option value="new_selection">Add to new selection</option>
<option value="delete_selected">Delete selected projects</option>
</select></label>
<button type="submit" class="button" title="Run the selected action" name="index" value="1">Go</button>
</div>
<div id="ajax_table_result">
<table cellspacing="5">
...
</thead>
<tbody>
...
</tbody>
</table>
</div>
</form>
Remember to wrap your results in the jQuery wrapper to use jQuery methods against it.
$.get("script.php", {foo:"bar"}, function(results){
var table = $("table", results);
/* from comments: how to get span.step-links */
var spans = $("span.step-links", results);
}, "html");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With