236 posts
  • Author Level 5
  • Beta Tester
  • Collector Level 1
  • Exclusive Author
+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

204 posts
  • Author Level 6
  • Featured Author
  • Freebie
  • 3 Years of Membership
+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
  • Author Level 5
  • Beta Tester
  • Collector Level 1
  • Exclusive Author
+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