Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make jQuery AJAX have a non-javascript (non-ajax) fallback?

I've gotten a fair amount of work done on my latest project, but I've realized there's a bit of a problem: If you don't have a Javascript-enabled browser, you can't submit any forms because every form uses AJAX to submit it.

My question to you all: How can I implement some sort of "fallback" so that if they don't have Javascript enabled, they can still submit the form.

Currently I have a banner along the header that says "For the optimal (and by "optimal," we mean "actually working") experience, please enable Javascript in your browser." but that seems like less than the optimal solution.

Thanks!

like image 862
Jacob Brunson Avatar asked Jan 18 '23 01:01

Jacob Brunson


1 Answers

For a form, you need to supply method and action attributes to the form tag that contains your inputs. Then actually make it submit there via a submit button. Once that works, then override it with your jquery. Et voila.

This is the big thing about progressive web, you can develop pages that work without javascript. One practical way to solve any problem is to figure out what you'd have needed to do if you never used JS in the first place.

Many developers out there don't believe you should even have a fallback though... its seems to be a hot ideological debate.

like image 186
Kristian Avatar answered Jan 29 '23 12:01

Kristian