Home › Forums › JavaScript › Cache form?
- This topic is empty.
-
AuthorPosts
-
July 21, 2014 at 9:40 am #176042nixnerdParticipant
Hey all, I’m wondering how I might go about using cache on a form? I’m not even sure if I’m saying that right.
Basically, what I want is a form where the person fills out their info and it’s processed with JS. Then, it just says “Message Sent!” with no page reload. Then, it is somehow sent to the server when they leave for further processing.
Obviously, I don’t want to JUST use JS to process a form. That’s crazy. And… I don’t want a page refresh… so I’m wondering how I can have both.
I’m assuming Node.js would be PERFECT for this.
Here is an example:
It’s at the bottom.
BTW, I’m just assuming this guy is processing his forms on the server. But the interaction is so beautiful and I want it.
July 21, 2014 at 9:46 am #176043shaneismeParticipantWell you can use JUST JS if your whole stack is JS!
I don’t have an easy way to do this myself. The last time I built one it was in PHP, and I simply had everything write to the database and any row that wasn’t marked as completed after X hours was deleted. Doing this with AJAX isn’t a huge leap.
But these days, I’d use something like Meteor JS to build my stack and it has stuff built in that does what you like. It’s still in a public preview though, but I have been tooling around with it and have been amazed at how easy it is to do something like what you want in a very short period of time.
July 21, 2014 at 10:18 am #176046TheDutchCoderParticipantYou can write a proxy php file that does the actual form validation and then just call it through an AJAX request with (e.g.) jQuery.
It’s not that hard to do, it’s secure (because the actual validation is done in PHP) and it allows you to stay on the same page (awesome!).
This might be a good start:
http://blog.teamtreehouse.com/create-ajax-contact-formJuly 21, 2014 at 1:03 pm #176084nixnerdParticipantWell you can use JUST JS if your whole stack is JS!
See, this is intriguing. Because this is actually for my personal site. So, I control the entire stack. I’m already using JS for templating and all kinds of other stuff. Why not just use Node.js/Express to process it on the server? I’m actually using Node.js already for Ghost. So, why not just use it to process forms?
Any good tuts for Node form processing?
July 21, 2014 at 7:20 pm #176120__ParticipantIf you’re not using multipart forms (i.e., file uploads), body-parser is probably your best bet.
-
AuthorPosts
- The forum ‘JavaScript’ is closed to new topics and replies.