Run function in the background after form submission response in wordpress

I have a function for submitting a form with ajax. After the submission i get a response.

function myform() {
   //run script here

   // get the results and show in the console that the form submission was successful 
   echo json_encode($results);

   // now call another function to process a script in the background after response
   my_background_function();


}

The problem now if the form is submitted, it will show the response only after the function my_background_function() is done.

How to run `my_background_function()' after form successfully submitted?



Read more here: https://stackoverflow.com/questions/64414943/run-function-in-the-background-after-form-submission-response-in-wordpress

Content Attribution

This content was originally published by Nash at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: