Yo driven,
I just wrestled with this the other day. What I ended up doing looks like
this:
var d = $(data); // jQuery-ize response, will be an array of nodes
for(i=0;i<d.length;i++) {
var node = d[i];
if (node.name && node.name == 'description') // bingo!
return node.text();
}
-- Josh
----- Original Message -----
From: "driven" <[EMAIL PROTECTED]>
To: "jQuery (English)" <[email protected]>
Sent: Wednesday, December 05, 2007 11:33 AM
Subject: [jQuery] parsing ajax html responses
Hi,
I am trying to accomplish something with the cluetip plugin, but it
really has more to do with parsing ajax html responses.
What I have is a search results page. I am using the href attribute as
the url for my ajax request. What I get back is a fully formed html
document as a string. The default behavior of the cluetip plugin is to
populate the tooltip with that entire response (minus the meta, title,
script etc. tags).
What I really want is the contents of the meta description tag in the
response to populate the tooltip. Unfortunately parsing a fully formed
html string isn't as easy as an xml string. I tried $
(data).find([EMAIL PROTECTED]).attr('content'); but that didn't
work.
I think the area of the plugin settings I need to mettle with is:
// process data retrieved via xhr before it's displayed
ajaxProcess: function(data) {
// I want the contents of the meta description tag
//data = $
(data).find([EMAIL PROTECTED]).attr('content');
data = $(data).not('style, meta, link, script,
title');
return data;
}
Any suggestions out there?
Thanks,
-Dan