mudradimohan Posted February 25, 2015 Share Posted February 25, 2015 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. Quote Link to comment https://forums.phpfreaks.com/topic/294890-background-process-using-php/ Share on other sites More sharing options...
rwhite35 Posted February 25, 2015 Share Posted February 25, 2015 (edited) 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 February 25, 2015 by rwhite35 Quote Link to comment https://forums.phpfreaks.com/topic/294890-background-process-using-php/#findComment-1506704 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.