weixin_33670713 2018-07-06 01:32 采纳率: 0%
浏览 14

带有jQuery的html中的Ajax链接

Anyone know how we create a ajax link when we click any href link or input / button, it's work in ajax?

  • 写回答

1条回答 默认 最新

  • weixin_33712881 2018-07-06 01:48
    关注

    You have to event.preventDefault() in your event handler to prevent the browser from trying to browse to the link. Other than that it should be business as usual.

    $(document).on("click", "a,input,button", function(event){
       event.preventDefault();
       $.ajax(...);
    });
    
    评论

报告相同问题?