What do you use and why?
AJAX is the better way to submit data, because:
Conclusion: With AJAX you can provide the user with a much better user experience!
In form posting , you cannot manipulate DOM say put a loading icon, hide submit button from posting multiple AJAX request, i still don't know why people prefer form posting it's DHTML syntax formed when AJAX was not even in it's craddle
To me this isn't a question of "or"... at least not if building a website!
There's an old joke called "the unwritten rule of JavaScript" -- it goes "If you cannot make a fully working page without JavaScript FIRST, you likely have zero damned business adding scripting to it!"
It plays to the notion of graceful degradation; JavaScript on a website should be an enhancement. It should enhance functionality, but NEVER replace it. Not all UA's provide JavaScript, not all Users ALLOW javascript either by choice or because of rules in the workplace from a security standpoint. Fat bloated JS has caused users on mobile to block it for the fact that such idiocy wastes battery for nothing of real value -- particularly as bloated scripttard BS like React, jQuery, Angular and so forth piss all over the accessibility, speed and functionality of websites!
Assuming it's a normal form, you HAVE to double-check ALL of your values server-side ANYWAYS -- even if you are using xmlHttpRequest to pass it, ALL user input is ALWAYS suspect and must ALWAYS be rechecked again... so is it REALLY so hard to make a working form with working data and working server side validation FIRST? That should be your FIRST job REGARDLESS of if you are going to add scripting or not!
AJAX style requests should be an enhancement -- prevent an unneccessary page-load on error, make the load of the result smoother, etc, etc... but that doesn't mean that if you can make it work without the scripttardery that you shouldn't... making it work without the scripting FIRST is in fact the first step... what should be done BEFORE you even THINK about scripting.
Of course, a LOT of the paranoid BS about "pageloads are evil" that sends people diving for scripting in the first place would be non-issues if people used minimalist semantic markup, practiced separation of presentation from content, didn't bloat down their pages with scripting only elements and static scripting in the markup, and bothered leveraging caching models. When you have 50 to 100k of markup, 500k to a megabyte of scripttardery spanning several dozen files, and several hundred K of ineptly developed sleazed together off the shelf CSS (thanks to ignorant BS like bootcrap) to deliver a 6 element form and 1.5k of plaintext, of course you're going to think that the scripted solution loads smoother or "saves" you bandwidth even if it tacks another dozen K onto the project.
When you are using 32k in 3 files for HTML, CSS and Scripting COMBINED to do the same job -- not so much. There's a reason I don't even bother with scripting enhancement on contact forms anymore! When the resubmit on error is only 6k of uncompressed markup (around 1.2k gzipped), the size of whatever the user typed in, and EVERYTHING else on the page is already cached -- why am I going to waste scripting on processing that?
But no, people will throw the bloated halfwit steaming pile of manure known as jQuery at it, have built their site with OOCSS style asshattery like bootcrap, THEN throw an even more bloated slow loading pile of crap form validator at it, and then wonder why their hosting costs are so high or nobody is even able to use their form.
Mind you, that's WEBSITES. Applications built with node.js, nw.js, electron, metro, etc, etc... that's a whole different ballgame since you KNOW that scripting is available, you KNOW that you have already told users with accessibility needs to go plow themselves, so you can ignore all that.
But on a website where accessibility is job one and everything else can take a flying leap? Not so much. Sadly, far, FAR too many websites right now are telling large swaths of users to go suck an egg thanks to bloated scripttardery, artsy fartsy "gee ain't it neat" BS, and a general ignorance of semantics, accessibility, usability, and good development practices.
Just look at 99.99% of the idioitic nube-predating scam artist BS found at the template whorehouses like ThemeForest or TemplateMonster; I truly pity the ignorant fools dumb enough to think any of that crap is worth a penny.
Luiz Estácio
Fullstack Developer
I use in the more cases AJAX. Because I can control the flows (success, error, ...) and it seems to be more user friendly.