I load some HTML via $.get(); I only want some parts of the result inserted into my html. So searched SO found this questions and then tried this:
$("a.load").click(function() {
$.get(this.href, {}, function(result) {
content = $("#main", result);
console.log(content);
}, "html");
return false;
});
Though result
has the correct contents console.log(content)
returns []
. Anyone an idea what I'm doing wrong?
Thanks in advance!
If you're trying to do what it sounds like you are, .load() would be easier:
$("a.load").click(function() {
$("#WhereYouWantHTMLInjected").load(this.href + ' #main');
return false;
});