My ajax (jquery) response (html) gives me a whole junk of html source code since it fetches the enrite page.
The response is somewhat like below:
<html>
<head>
...
...
</head>
<body>
.
.....
.
.......
<div id="content">
content i want to extract
</div>
.............
..........
.............
</body>
</html>
I need help with the following:
1) Is it possible to read just whatever is between the <div id='content'></div>
? if yes, how?
2) if #1 is not possible, how could I extract just the content from the <div id='content'></div>
?
The code I tried:
/*Ajax*/
$jq(function(){
alert ("Doc ready");
$jq("#content a.next-page").bind("click", function(e){
alert ("Hey!");
/*Make the call*/
$jq.ajax({
url: "/page/2",
type: "get",
cache: false,
data: "",
error: function(){alert ("No data found for your search.");},
success: function(results){
//$searchPanel.find("tbody").empty().append(results);
//$searchPanelHolder.css({"display":"block"});
alert (results.find("div[id='content']").html());
e.preventDefault();
}
});
e.preventDefault();
});
});
Any help on this is much appreciated
Many thanks, Racky
what about this?
$("#content", 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