Let's say I do a simple AJAX request (in jQuery) like geturl.php?url=http://google.com
and geturl.php
is this:
<?php
if($_GET['url'])
{
$url=$_GET['url'];
echo file_get_contents($url);
}
?>
Simple, right?
How would I grab the META description from the returned (really long) string in jQuery?
Here's what I have so far. Yes, I know, desc
is wrong.
$.get("geturl.php?url="+url,function(response)
{
// Loading <title></title>data
var title=(/<title>(.*?)<\/title>/m).exec(response)[1];
var desc = $("meta[name=description]").val();
$("#linkbox").html("<div><b>"+title+"</b><br/>"+url+"<br />Desc: " + desc)
});