thank you for teaching
I have read the AJAX and JSON lesson
Gently : would you use JSON “always” or are there situations where other manners are preferable?
e.g. just variables
e.g. how to handle AJAX / AJAJ tables with pagination and filters and sorting (I don’t mean re- code datatables from scratch but it is a good example)
or it is matter of the rsponse
e.g. receive variables from the controller or receive html for some of the DOM elements
thank you in advance if you’ll expand your lesson with this (eventual) distinctions or confirmation (use always json) or what ever
Like most things in programming, AJAX and JSON are both tools. Sometimes they’re the right choice, but other times they aren’t. It’s hard to be more specific than that, because so much depends on the context of whatever you’re working on.
So sure, sometimes it might make more sense to use form data rather than encoding your data as JSON. Or it might make sense to return a simple value or text value. It all depends.
Thank you for your kind reply
I guessed something like that
But as teacher , don’t you want to kindly give some guidelines for the best approach with some common situations?
Ok, what common situations are
- tables of values used as form (e.g. columns and rows of an inventory)
- multiple fields of an input page
- I’m sure you’ll have a couple more
- e.g. the way you load and submit this reply form when you click the edit icon
yes the argument is wide
but some hints for those that in your opinion are common tasks… well it would be welcome.
Yes in the end coding is something subjective , and with practice you’ll recognize or stick with the methid that is good for you for that application
… but in the beginning, some inputs and hints are welcome, call them suggestions
P.S. what about the more recent fetch() ? With Google and Microsoft that are controlling the world (at least at browsers level) today as today there are almost no more outdated browser, since they obligate you to update it or you find it updated.