4
4
4eloBek2015-09-20 07:23:07
JavaScript
4eloBek, 2015-09-20 07:23:07

How to change title dynamically via ajax request?

Here is a JS example :

<br>
var url = "test.html";<br>
$('title').load('/'+url+' title');<br>


Outcome: nothing happens (
Help me figure it out)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MK, 2015-09-20
@4eloBek

var x=XMLHttpRequest();
x.open("get","test.html",true);
x.onload=function(){
document.title=x.responseText;
};
x.send(null);

If jQuery is included:
But connecting just for this is a crazy idea.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question