{"id":2792,"date":"2022-08-30T15:27:49","date_gmt":"2022-08-30T15:27:49","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/02\/16\/jquery-live-and-submit-problem-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:27:49","modified_gmt":"2022-08-30T15:27:49","slug":"jquery-live-and-submit-problem-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/jquery-live-and-submit-problem-collection-of-common-programming-errors\/","title":{"rendered":"JQuery `live()` and `submit()` problem-Collection of common programming errors"},"content":{"rendered":"<p>I wanna do something like this, but this one looks like happing for infinite times.<\/p>\n<pre><code>$(\"form\").live(\"submit\", function() { \n\n    if($(this).attr('action') != \"ajax\"){\n        $(this).submit();\nreturn true; \/\/ even i do this!! but form is NOT submited!!\n}\n\nelse { \/* doing the ajax stuff! *\/ }\n});\n<\/code><\/pre>\n<p>in Chrome and Firefox after a while the form gets submitted, something like 10seconds and in IE it crashes !<\/p>\n<p>I know when i say form.submit means that i am submitting this and get called function again and again, how can i avoid this ?<\/p>\n<p id=\"rop\"><small>Originally posted 2014-02-16 14:42:22. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I wanna do something like this, but this one looks like happing for infinite times. $(&#8220;form&#8221;).live(&#8220;submit&#8221;, function() { if($(this).attr(&#8216;action&#8217;) != &#8220;ajax&#8221;){ $(this).submit(); return true; \/\/ even i do this!! but form is NOT submited!! } else { \/* doing the ajax stuff! *\/ } }); in Chrome and Firefox after a while the form gets [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2792","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2792","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2792"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2792\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2792"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2792"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2792"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}