Home  >  Article  >  Web Front-end  >  Precautions for using jquery's live_jquery

Precautions for using jquery's live_jquery

WBOY
WBOYOriginal
2016-05-16 16:59:311097browse

-------------------------- Title

Recently, I encountered a very strange problem in development. When a button is clicked to submit, multiple errors occur. requests, resulting in data duplication.

Then, after debugging, it was found that the cause of the problem is $("#id").live("click", function() {}); in this live, if you use bind, it may not be achieved Requirement, because if the returned request after an asynchronous request is html instead of json, the bind component may fail when the page is refreshed using html.

-------------------------- Solution

So, in the end, it can only be on the html tag element Add onclick attribute to solve it.

This not only solves the problem of asynchronous return of html format, but also solves the problem of multiple requests on one click caused by multiple bindings caused by multiple html() refreshes of the page (including the js part). bug.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn