236 posts
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 3-4 years
  • Bought between 1 and 9 items
  • Microlancer Beta Tester
GradaStudio says
hey guys have a quick question i am tracking link clicks with ajax. i have some html code like this
<a href="googl.com" class="my-link"></a>link
and some jquery code like this
$('a.my-link').live('click', function() {
$.ajax({----------});
});

is there any change that link will open before the ajax callback is made ? thanks

185 posts
  • Author had a Free File of the Month
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 1-2 years
  • Exclusive Author
  • Bought between 1 and 9 items
  • Europe
ikaruna says

hey guys have a quick question i am tracking link clicks with ajax. i have some html code like this
<a href="googl.com" class="my-link"></a>link
and some jquery code like this
$('a.my-link').live('click', function() {
$.ajax({----------});
});
is there any change that link will open before the ajax callback is made ? thanks
If you ask me “Yes there is!”, I guess you should make sure that the ajax request was completed, than proceed opening the page. Ex:
function click(e){
e.preventDefault();
currentLink = jQuery(this).attr('href');
ajax.call(callback)
}

function callback(){
//could be error
//could be success
//now open the URL(currentLink)
}

Anyway I think this would be bad practice (for all links) – pretty heavy for the server, no to mention that user would wait a couple of seconds before you get the ajax response.

jayc

236 posts
  • Exclusive Author
  • Sold between 10 000 and 50 000 dollars
  • Has been a member for 3-4 years
  • Bought between 1 and 9 items
  • Microlancer Beta Tester
GradaStudio says

thanks SakuraPixel exactly no one likes to wait just to open a link. so its not a practical idea. as i can see in my plugin right now ajax click tracking works fine without adding any complexity.

by
by
by
by
by
by