click on the button to run php code and echo result -


i want implement script: http://www.daniloaz.com/en/560/programming/backup-de-bases-de-datos-mysql-con-php/

on website backup database @ end of day.

may know possible me put button click , run script , echo status after finish without refreshing page or bring me new page.

as @ moment everyday need go link: www.example.com/backup.php daily backup, want ease job :)

any idea how this?

what type of button? if html yes it's easy

have button on ever page want along div so:

<input type="button" name="perform_backup"  onclick="do_backup()"><div id="results"> no backup has been performed yet</> 

then have javascript calls backup php script

<script>    function do_backup(){    var xhreq = new xmlhttprequest();    var request = "http://www.example.com/backup.php " // prepare request server    xhreq.open("get", request, false);  // send request    xhreq.send(null);    document.getelementsbyid("results").innerhtml=xhreq.responsetext  /// display results     } </script> 

then modify script on server give more boolean variable that's you. whatever choose seen inside <div id="results"> , without loading new page... method called ajax future questions


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -