236 posts
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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

203 posts
  • Has sold $40,000+ on Envato Market
  • Made it to the Authors' Hall of Fame
  • Contributed a free file of the month
  • Has been part of the Envato Community for over 2 years
+3 more
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
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 1+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
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