42311

How to cancel submit on AjaxForm

i'm working with jquery plugin(ajax form), i try to implementing something like this

$("#MyFormID").ajaxForm({ dataType: "json", resetForm: true, beforeSubmit: function() { //validateData returns boolean if(validateData()){ // continue submit }else{ //cancel submit } }, success: function(json) { //show success notification } });

is there a way to stop the ajax from submiting the form?. on beeforesubmit function maybe?

Answer1:

You can use return false; in beforeSubmit function to prevent form submission.

Source: http://jquery.malsup.com/form/#options-object

Answer2:

Call xhr.abort() in beforeSend callback.

Recommend

  • Set a minimum limit in a custom multifield component
  • Resetting Form When modalpop up gets closed if i click any place in my page
  • JSON - Not working in Internet Explorer 8
  • Kotlin's kapt plugin for gradle does not work for custom source set (JMH)
  • Caliburn Micro, How to use ContentControl (or display 'sub' ViewModel) using ViewModel Fir
  • Perspective projection, 4 points
  • Yii2: Finding file and getting path in a directory tree
  • Default parameter as generic type
  • UWP/C# - Issue with AQS and USB Devices
  • How can I display the parent menu item's description using Wordpress walkers?
  • Button click event not firing in jQuery
  • Eloquent paginate function in Slim 3 project using twig
  • How to determine if there are bytes available to be read from boost:asio:serial_port
  • Retrieve list of sent friend requests from friend_request FQL table
  • How to suppress a dialog
  • java inputstream
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • JSON response opens as a file, but I can't access it with JavaScript
  • Cancel a live stream “fast motion” catch-up in Flash
  • why do I get the error when installing the gem 'pg'? [duplicate]
  • Can I check if a recipient has an automatic reply before I send an email?
  • Handling un-mapped Rest path
  • FileReader+canvas image loading problem
  • Using jQuery closest() method with class selector
  • Why value captured by reference in lambda is broken? [duplicate]
  • Regex thinks I'm nesting, but I'm not
  • req.body is undefined - nodejs
  • Fill an image in a square container while keeping aspect ratio
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Change div Background jquery
  • sending mail using smtp is too slow
  • Busy indicator not showing up in wpf window [duplicate]
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Reading document lines to the user (python)
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • Net Present Value in Excel for Grouped Recurring CF
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?