Execute jQuery after form submit I have a non-ajax form for which I'm trying to execute a jQuery function after the form has been submitted and processed.

I don't need ajax for the form, but I do need to wait until 600 odd form fields have been processed before executing my jQuery function.

There are a lot of answers out there, but I can't quite figure them out.

Should I do this via ajax (even though not required for the form) or is there a better way to do it?

Given the form takes a good few seconds (10 or so) to process (more on mobile, etc.) how should I go about it?

EDIT:

Another go at explaining exactly what I'm trying to do.


I have a form that collects 600+ pieces of data
After the form has been submitted and processed, I need to open a new window that processes the data, displaying it graphically (via canvas) and then saves that canvas as an image to the user profile.


Because there is so much data that needs to be processed, I've elected to run everything in a new window, so if the user navigates away from the main window, their canvas is drawn and saved, etc. in the background.

It appears that jQuery is the only way to open this new window, and I have to execute this after the form submission (otherwise the canvas is drawn with pre-submitted data)

Of course, there could be a better end to end way to do it, but jQuery post form submit seems to be it.
You can use Drupal.behaviors, which is fired upon page load.

function doSomething()
{
  // Do something
}

Drupal.behaviors.myModule = {
  attach:function() {
    doSomething();
  }
};