$('#id').click( function(event) { $.ajax({ type:"post", url:"", data:null, dataType:"json", async:false, success:function(data){ } }); });
发现非button标签会执行两次ajax事件。经查是标签之间的传递性导致的。只需要加一行代码即可。
$('#id').click( function(event) { $.ajax({ type:"post", url:"", data:null, dataType:"json", async:false, success:function(data){ } }); //添加代码 event.stopPropagation(); });
参考文章: http://www.365mini.com/page/jquery-event-stoppropagation.htm