Creating a separate PHP file for each class will certainly be more maintainable, if at all it is a project of any size. It will also allow you to do something like class-based server level authentication.
On the JavaScript side, you definitely need some kind of AJAX library, regardless of whether you are going to build it (I did it once in about 50 lines of JavaScript) or used one of them. You might need a helper function or two that know how to serialize data (XML, JSON, limited, whatever).
You can write object-oriented code in JavaScript, and if you already do this, it makes sense to add the write () or updateServer () method to call the AJAX library with the correct parameters for consistency. If you are not writing OO code, it may still make sense to have separate functions, but only if you need to save no more than one place.
source share