像这样
HTML
<a href="/Default/link.html" data-endpoint="/Ajax/link.html" data-target="targetId" data-cache="false", data-async="true">Click me!</a>
jQuery
$('a[data-async="true"]').click(function(e){ e.preventDefault(); var self = $(this), url = self.data('endpoint'), target = self.data('target'), cache = self.data('cache'); $.ajax({ url: url, cache : cache, success: function(data){ if (target !== 'undefined'){ $('#'+target).html( data ); } } });});
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)