I am pretty new to jQuery but so far I love it. I am working on a personal portfolio site, the links in my menu use the .load() method to load the content of the links target into my content div. Here is the function I used :
//Loads the content of the link into the div
$("a").click(function(ev){
ev.preventDefault();
var link = $(this).attr("href");
$("#content").load(link);
}
});
It works fine... at first. However after I have been on the site for awhile and have clicked links a few times it seems to slow way down, and can get sort of.. choppy, and strage flicking from one page to another.
I noticed that when I have Firebug open and am clicking the links it is making multiple AJAX calls with each click. I can see this in the console. It seems that the number of calls increases exponetially - 2 for the first click, 4 for the next, 8 for the next and so on. What gets written to the console is :
GET http://localhost/Portfolio/javascript.js 200 OK 4ms GET http://localhost/Portfolio/filename.php 200 OK 44ms
The javascript file is, of course, the file with the function in it, and filename is whatever the name of the file the link I click is going to. It seems like half the calls are to the Javascript file and half to the links target, that is if there are 8 made then 4 are to the javascript file and 4 to the php file.
I am sort of at a loss for why this is happening here. Any advice or ideas anyone has as to why this is happening would be very much appreciated. Thanks very much.
This post has been edited by Jstall: 06 May 2010 - 01:03 PM

New Topic/Question
Reply



MultiQuote




|