Skip to content

Instantly share code, notes, and snippets.

@jinzhu
Created March 23, 2009 02:05
Show Gist options
  • Save jinzhu/83385 to your computer and use it in GitHub Desktop.
Save jinzhu/83385 to your computer and use it in GitHub Desktop.
$.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