views:

64

answers:

2

I've created an ajax sign up form using jquery to a PHP backend. My question is whether it's prudent to leave the form attribute action="", that is between blank quotation marks and let the ajax interface handle everything. Are there any pitfalls to this method if I'm not interested in users with javascript turned off?

$('#signUp').bind('click', function(event) { event.preventDefault(); ...form validation...

$.ajax({ type: 'POST', url: '../formToProcess/processor.php', data: enlistee, success: function() { });

A: 

Since you are already using the Form tag, having the page degrade gracefully won't kill you. Especially since all you need to do is point the action attribute to the same url and reuse the logic you already have in the backend. But if you really don't care about graceful degradation, it won't make any difference aside from the browser trying to send the form data to a non-existent url.

JoseMarmolejos
+2  A: 

I would always have a full fallback system in place, that acts as if Ajax and/or JS doesn't exist. Assume users are going to either have JS turned off for security purposes, etc or that malicious users will get around whatever client-side validation you have in place.

bdl