There's a few issues here. Firstly you need to pass a function reference to success. By invoking the function immediately you're actually assigning its return value to success, hence nothing appears to happen. To fix that simply remove the parentheses from the function name:
success: ajaxCartFormSubmitted,
Next, to have modalopen() execute after ajaxCartFormSubmitted() you need to call it at that time. Passing the name of the function as an argument alone is not enough. You need to expressly call the function. You can either do this in ajaxCartFormSubmitted():
function ajaxCartFormSubmitted(e) { // do something... modalopen(); });
Alternatively you can provide an anonymous function to success which calls both functions:
success: function() { ajaxCartFormSubmitted(); modalopen(); },
Finally, a couple of notes. You need to update jQuery as 1.3 is over 10 years out of date. 3.4 is the latest version. Also I'd be careful with your function names. You appear to have both openmodal() and modalopen(), and that kind of similarity is just asking for problems.
Edit
The ajaxCartFormSubmitted function contains another function which needs some time to process. That is why I need to call my function after ajaxCartFormSubmitted
In which case you need to implement the callback pattern, as $.ajax() does, yourself. You can make ajaxCartFormSubmitted() accept a function as an argument which will be executed after the async operation completes, like this:
// in $.ajax settings: success: function() { ajaxCartFormSubmitted(openmodal); } // function definition: function ajaxCartFormSubmitted(cb) { some.longRunningOperation({ oncomplete: function() { cb && cb(); // invoke the function you passed in here, openmodal() in this case } }); }
success: ajaxCartFormSubmitted,. Secondly note that jQuery 1.3 is over 10 years out of date. You need to update itreturn $.ajax(...and use.done()