I am trying to get some page details (page name, image on the page, etc.) of an arbitrarily entered URL / page. I have a back-end proxy script that I use via ajax GET to return the full HTML address of the remote page. As soon as I get the ajax response back, I try to run several jQuery selectors to extract page details. Here's a general idea:
$.ajax({
type: "GET",
url: base_url + "/Services/Proxy.aspx?url=" + url,
success: function (data) {
var potential_images = $("img", data);
var name = $(data).filter("title").first().text();
var description = $(data).filter("meta[name='description']").attr("content");
}
});
Sometimes use $("selector", data)seems to work, while at other times it $(data).filter("selector")works. Sometimes it doesnβt work. When I just check the contents $(data), it seems that some nodes go through, but some just disappear. Does anyone know a consistent way to run selectors on a full line of HTML?