spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories

jQuery submit 'this' form


Change

$(form).submit();

to

form.submit();

When you call submit on a jQuery object, it calls your submit handler again. Calling it directly on the DOM element does not.

Example (interestingly, Stack Snippets won't let me submit a form, not even with target="_blank"):

var nesting = 0;
function submitHandler(form) {
  var which =
$(form).find("input[type=radio]:checked").val();
  ++nesting;
  if (nesting > 5) {
    snippet.log("Nested to 5, gave up");
  } else {
    if (which === "jQuery") {
      snippet.log("Calling via jQuery, nesting = "
+ nesting);
      $(form).submit();
    } else {
      snippet.log("Calling via DOM, nesting = " +
nesting);
      form.submit();
    }
  }
  --nesting;
  return false;
}
<form id="the-form"
      onsubmit="return submitHandler(this);"
      action="http://www.google.com/search"
      target="_blank"
      method="GET">
  <input type="text" name="q"
value="kittens">
  <div>
    <label>
      <input type="radio" name="opts"
value="jQuery"> Submit with jQuery
    </label>
  </div>
  <div>
    <label>
      <input type="radio" name="opts"
value="DOM"> Submit with DOM
    </label>
  </div>
  <button>Submit</button>
</form>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<!-- Script provides the `snippet` object, see
http://meta.stackexchange.com/a/242144/134069
-->
<script
src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script>


Categories : Javascript

Related to : jQuery submit 'this' form
Jquery to serialize and submit form among several other forms
var $this = $(this); var tzip = $this.find('input.zip').val(); The problem here is that $(this) here select your submit button and not your form. Therefore $this.find('input.zip').val() does not return any value since there in no 'input.zip' in your submit button. To fix the problem you should replace this line with somthing like that for example: var tzip = $this.parent('form').find('input.zip

Categories : PHP
Delaying the Submit button click using Jquery
You can register a callback function on a button and subsequently remove that callback using the jquery off method. This means that when the submit button is pressed, you can remove the event handler and then set a timer that will subsequently re-add it after a period of time when the timer fires. You can use the window.setTimer() function to register a function to be called after a period of ti

Categories : Javascript
Jquery Dialog submit button not firing sometimes
Try the following alterations: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> and $("[id*=JobSeekerLogin]").on("click", function () { $("#login-content").dialog({ open: function(type,data) { $(this).parent().appendTo("form"); }, title: "JOB SEEKER LOGIN", width: 600, modal: true, });

Categories : Jquery
Show loading gif after clicking form submit using jQuery
The show() method only affects the display CSS setting. If you want to set the visibility you need to do it directly. Also, the .load_button element is a button and does not raise a submit event. You would need to change your selector to the form for that to work: $('#login_form').submit(function() { $('#gif').css('visibility', 'visible'); return true; });

Categories : Javascript
Geocoder search fails when jquery submit() is used instead of submit_tag in rails
Fixed by moving the form submit into the geocoderAddress() function. Someone else more clever noted that this is a asynchronous request and the form should not be submitted until after the Google Maps API has replied and the hidden fields have been populated. Current JS var client_geocoder; function initialize() { client_geocoder = new google.maps.Geocoder(); } function geocodeAddressThenSu

Categories : Javascript
Recently Add
How to add items to sharepoint list from a html document?
Copying App Package Folder To Isolated Storage For Windows Store App
javascript save file from (sinatra's) streaming response
Use routeParams to create templateUrl in AngularJS
resize image using javascript
How to add and remove div's (input)
Onsen UI sliding menu
BxSlider is working but there is a blank space inside div
on button click delete from datatable and also from array
Jquery changing table th tag is not working properly
Get file height width before uploading using Javascript / Asp.net
Break out of Bootstrap modal dialog if unauthenticated
Listener for click on ANY element and read particular HTML-5 custom attribute when present?
What is the best way to use this in prototype method
Get Latitue and Longitude of the center in google map when draged
Jquery multidimensional Json parse
Not able to format date
How to force y position of one branch in d3 sankey plugin?
radio button doesn't come up from JS file
Calling PHP webservice method from Javascript/jQuery
Responsive menu - parent menu with link
'click' event firing multiple times, no solutions working
How to create Cordova Blackberry (Hybrid) application
Javascript date picker multiple select
How to do the marker management in google map
JQuery/Ajax Unexpected Identifier error
AngularJS Promise error catching
Populate form from child object
Jquery popup with scrollbar and column alignment
OpenLayers3 control panel
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.