1) If you want to perform certain operation as a first activity after the save button click, then you would have achieved it via server side script (here PHP) by hooking into some action, but as you are clearly specifying that you want client side action only, I think there is no straightforward way to control the order of the even like
click. However, one following can be done -
func1() should execute first and then
func2(), so just call these in that order.
OR if this approach doesn't completely execute your JS function first, then you can use
.submit() is available in jQuery
3) Apart from these, I have one more way which I'm not completely sure but may help you -
Can you use
onfocus event instead? This will execute before click and will work with mouse as well as keyboard.
But, a disadvantage is that it will always execute your script irrespective of whether the user actually submitted the form or not.
4) WordPress widget saves the widget form via ajax, so you can check if there is any hook available where you can inject your script and get your script executed before the form entry is actually made in database.