Please enable JavaScript to view this site.

Navigation: Advanced topics > Programming topics > JavaScript API > AJAX helper object > Methods

JavaScript API: AJAX helper object > submit()

Scroll Prev Next More

 

The submit() method starts the Server part of the event, when the basic routine can not be used.

 

When the Client Before part of the Custom button event runs an asynchronous task (for example, displaying a dialog and waiting for the user's answer, or creating a PDF file), the event must return false. Otherwise the Server part runs immediately, before the asynchronous task ends.

 

Call the submit() function after the asynchronous task has finished to pass control to the Server event.

Syntax

ajax.submit();
 
//or
 
submit();
 
//you can use either one

Arguments

No arguments.

Return value

No return value.

Example 1

Postpone the Server event for five seconds.
 

// postpone the Server event by 5 seconds
setTimeout( function() {
submit();
}, 5000 );
return false;

Example 2
 
A more complete examples that uses Sweetalert confirmation dialog. We are adding this code to custom button's ClientBefore event. We want to proceed with the Server  action only if "Yes, please" button was clicked. In order to do so we return false; at the end of ClientBefore event and in the code branch that handles "Yes, please" button click we issue submit() call.
 

swal("Would you like to delete this record?", {
 buttons: {
   cancel: "Nope",
   proceed: {
     text: "Yes, please",
     value: "proceed",
   }
 },
})
.then((value) => {
switch (value) {
 
  case "proceed":
     swal("Thanks, I'll go ahead");
     submit();
    break;
 
  default:
     swal("Gotcha!");
    break;
  }
});
return false;

See also:

Tri-part events: Asynchronous tasks

Dialog API

PDF API

JavaScript API: AJAX helper object

About JavaScript API