Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pierce111

macrumors newbie
Original poster
Aug 2, 2008
10
0
Hi everyone. I have been looking into how to save Javascript using PHP, but I have not been able to find any helpful answers. If anyone could show me how to save Javascript with either PHP or MYSQL, that would be great!
 
By "saving JavaScript", I mean taking the information that Javascript has put on the page (including forms) and save it to a MYSQL database (with PHP). If anyone needs any more clarification, feel free to ask!
 
By "saving JavaScript", I mean taking the information that Javascript has put on the page (including forms) and save it to a MYSQL database (with PHP). If anyone needs any more clarification, feel free to ask!

Well if the page has a form you can simply submit to a PHP script that will then save whatever you have in the form. You could also use AJAX to connect to a PHP script, which will store things in a database. There's an enormous amount of tutorials out there, just search for them.
 
Well if the page has a form you can simply submit to a PHP script that will then save whatever you have in the form. You could also use AJAX to connect to a PHP script, which will store things in a database. There's an enormous amount of tutorials out there, just search for them.

Hi. :) I probably should have specified more... I want to connect to PHP at intervals (or changes to the current text). However, I can't find any documentation for that...
 
Hi. :) I probably should have specified more... I want to connect to PHP at intervals (or changes to the current text). However, I can't find any documentation for that...

Yea, AJAX is what you want. AJAX can call PHP whenever you need, even automatically. See this Periodic Refresh AJAX Pattern for some details. Essentially you'll use JavaScript's setTimeout or setInterval functions to call some function every so many seconds.
 
Yea, AJAX is what you want. AJAX can call PHP whenever you need, even automatically. See this Periodic Refresh AJAX Pattern for some details. Essentially you'll use JavaScript's setTimeout or setInterval functions to call some function every so many seconds.

Thanks for your reply, and the link. Unfortunately, I am fairly new to Javascript, and completely new to AJAX... So most parts of the page don't make much sense to me. Do you think I would be better off researching the setTimeout or setInterval functions instead?
 
While probably not the best thing to do at the moment, you can always try using a framework. jQuery is pretty simple to execute AJAX calls with, however it might be overkill.
 
Thanks for your reply, and the link. Unfortunately, I am fairly new to Javascript, and completely new to AJAX... So most parts of the page don't make much sense to me. Do you think I would be better off researching the setTimeout or setInterval functions instead?

What you're wanting to do sounds to be over your head for the moment. Though if you have an existing PHP script that works, then using a JavaScript framework (as suggested by another person) would let you do AJAX without much knowledge. The setTimeout and setInterval are pretty easy functions to learn. I won't suggest any JavaScript frameworks as I don't use any myself. There's plenty of tutorials out there though for using them to do AJAX and should be easy enough to set it up with your PHP script, if that's done.

If you're going to want specific solutions and help though, you'll have to add much more detail in your post. Good luck.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.