Jump to content

Recommended Posts

Hi All,

 

I am Mohan. I am new to this forum. I need help. I am doing a client's task and I am stuck up. I am not able to proceed further. The requirement is:

 

I have a form on which I choose fromdate, todate and upload an excel sheet. and click submit.

This will open a page where I get a popup "some message. click on 'done'". There is a done button.

On clicking the done button, it will run a php script which will generate the report for the chosen parameters. So as long the report is generated, the page remains idle. If I click on any other link, the report generation is broken. and it opens the link which I clicked. Is there any way I can click the link and as well as the report is also generated in the background.

 

Kindly help me out with an example.

 

Thanks and Regards,

Mohan.

Link to comment
https://forums.phpfreaks.com/topic/294890-background-process-using-php/
Share on other sites

Hello Mohan,  look at AJAX.  Here is a code example:

/* assign vars, $text_id is a PHP var */
var txtid = <?php echo htmlspecialchars(json_encode($text_id), ENT_NOQUOTES); ?>;
var set_url = processPost.php //script to process user submit

/* post data to script that processes submit */
$.ajax({
    type: "POST",
    url: set_url,
    data: {pos_data: txtid},
    contentType: 'application/x-www-form-urlencoded; charset=UTF-8'
})
/* post execution ui feedback (promise interface) */
   .done (function(data) {
      if(console && console.log) {
        console.log("AJAX success: " + data);
      }
   })
   .fail(function(obj,status,error) {
        alert("AJAX Error:" + obj.error);
   })
   .always(function(){		//you may not want this
       location.reload();
   });
   //UI feedback on success
   alert("Change set! Click Save File to create a PDF");

NOTE: This is inside a JQuery code block with some PHP earlier in the same script. Use this as a learning path for your project.

Edited by rwhite35
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.