Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
12
rated 0 times [  17] [ 5]  / answers: 1 / hits: 18203  / 15 Years ago, fri, january 22, 2010, 12:00:00

So far...



$('#container').load(hash + ' #page','', function() { 
$('#container').fadeIn('fast');
document.title = $('#title').load(hash + ' #title').text();
});


...doesn't work.
Is there a better/correct way to do this?



FYI: -




  • I've added the ID #title the tag (all pages/it's a PHP template).

  • The container is .fade(ed)Out beforehand (less important)



Thanks in advance.


More From » ajax

 Answers
8

The problem is that, at the time you assign to document.title, the $('#title').load(hash + ' #title').text() might not have finished yet. Try setting the new document.title in the callback of that .load.



UPDATE



Try:



$('#container').load(hash + ' #page','', function() { 
$('#container').fadeIn('fast');
$('#title').load(hash + ' #title', '', function(data) {
document.title = $(this).text();
});
});

[#97776] Monday, January 18, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bethv

Total Points: 215
Total Questions: 101
Total Answers: 89

Location: Angola
Member since Wed, Jun 2, 2021
3 Years ago
;