Last active
December 19, 2015 17:29
-
-
Save denzuko/5991975 to your computer and use it in GitHub Desktop.
Post #form to a restful api
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var isPulse=true; | |
| function heartbeat(){ | |
| if(isPulse){ | |
| var hb = setTimeout(heartbeat, seconds*1000); | |
| //process stuff here | |
| //isPulse can be whatever you want. | |
| //It just needs to be something that will stop the recursive loop--an error condition, perhaps. | |
| //Having a condition to stop this is a good idea, otherwise it will start acting like a memory leak. | |
| //You could change the condition to be an amount of time, number of loops, or some other condition. | |
| $('form').change(function() | |
| { | |
| console.log('success!'); | |
| $.ajax({ | |
| type: 'post', | |
| url: 'process.php', | |
| data: $(this).serialize(), | |
| success: function() { | |
| } | |
| }); | |
| return false; | |
| }); | |
| } | |
| } | |
| //function call is here | |
| var hb = setTimeout(heartbeat, seconds*1000); //beat every 5 minutes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment