Jump to content

jQuery Ajax response isn't correct (navigation)


shortysbest

Recommended Posts

I've used jQuery ajax for quite some time but have always had this problem;

When you click around on the pages before the ajax request for the first click is finished sometimes it will not output the correct page (the last clicked page).

 

 

Let's say my navigation bar has these links:

 

Home--Messages--Account

 

sometimes when I click home, account, messages,  account (or any combination) quickly (which fires multiple ajax requests), if account is the last clicked link, sometimes it will load messages page instead, or home, whatever it may be, point is it's not the correct page.

 

Any ideas how to fix this? This a huge problem.

 

$(".profile-navigation a").click(function(){

var page = $(this).attr("id");
if(loaded_page==null||loaded_page!=page)
{
$(".profile-navigation a").removeClass("current");
$(this).addClass("current");

$.ajax({
type: "POST",
url: "ajax/profile/"+page+".php",
data: "id="+id,
cache: false,
success: function(html){

$(".profile-bottomright-wrapper").html(html);
loaded_page = page;

}
});

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.