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


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:

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: