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
+2 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.

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by