Created
March 23, 2009 02:05
-
-
Save jinzhu/83385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.ajaxLink = function() { | |
$(this).click(function(){ | |
$.ajax({ | |
url: $(this).attr('href'), | |
dataType: 'script', | |
}); | |
return false; | |
}); | |
}; | |
function initall() | |
{ | |
$('.ajaxlink').ajaxLink(); | |
} | |
$(document).ready(function() { | |
initall(); | |
}) | |
//if I call `initall();` once ,when I click a link will cause one ajax request | |
$(document).ready(function() { | |
initall(); | |
initall(); | |
}) | |
//but when I call `initall();` twice,when I click the link will cause two ajax request | |
//how Can click one link only cause one ajax request? no matter how much times call `initall()` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment