I'm trying to work out how to parse specific parts of a page using JQuery's AJAX method. What I'd like to do is something like this:
$.ajax({
url: "page-to-load.htm",
dataType: "html",
success: function (response) {
var html= $(response);
var content = html.find("#main");
var title = html.find("title");
var nav = html.find("ul.nav");
}
});
I know that I can load specific page parts using [container].load() but this will (as far as I understand it) create a request for each page part I want to load.
In my sample code, the html object seems to be an array of HTML elements but each of the objects returned by find() are null. The elements searched for do exist in the target page.
Am I missing something obvious or is this just not something that JQuery can handle?