Debar Debar - 9 months ago 37
Javascript Question

How to get title using ajax?

I'm using ajax functionality and trying to get title using ajax but not working. Here is a example

$('#ajaxlink').click(function(e) {
var $this = this.href;
url: $this,
dataType: 'html',
success: function(html) {
var div = $('title', $(html));



return false;

<script src=""></script>
<a id="ajaxlink" href="">Click</a>
<div id="gettitle">


Your request is failing because of CORS protection. You can't easily request html from other domains and parse the results, unless they have enabled CORS explicitly.

To make it work for same domain, try this