Debar Debar - 1 year ago 122
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">

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download