jquery - Retrieving text from the <title> element from the <head> in an ajax response -
so i'm pretty sure question has been answered , i've figured out how retrieve text out <title>
element stated here, when attempting ajax, firebug responds undefined
jquery('title', data).text()
.
//ajax next page function grab_nextpage(){ var nextpgelement = jquery('.swipe_arrow.right'); var nextpage = nextpgelement.find('a').attr('href'); jquery('.swipe_arrow.right').children('a').addclass('hover'); jquery.ajax({ url: nextpage, datatype: "html", success: function(data){ console.log(jquery('title', data).text()); jquery('title').text(jquery('title', data).text()); } }); }
update
the data
variable success: function(data){}
seems contain header/title
elements, .text()
seems inaccessible although jquery('title', data)
comes [object object]
(so object
seems accessible, contents not).
data http://iforce.co.nz/i/rm31s1fg.v31.png
object title
data
i guess might need this:
var url = 'http://google.com'; $.get("get_url.php?url="+url,function(response) { var title=(/<title>(.*?)<\/title>/m).exec(response)[1]; });
Comments
Post a Comment