The last couple of days I’ve been doing a ton of AJAX programming on some WordPress plugins. Wordpress actually does have one very handy AJAX feature that makes using AJAX just a little easier. I also use jQuery because it’s really nice for a lot of things including AJAX work.
AJAX is a great technology, and while I know what I’m doing, sometimes even I am amazed at how difficult it is. You’ve got HTML, Javascript, PHP, and usually database tables to get right. If any one of those isn’t working it won’t work.
If you don’t already have good debugging skills, I wouldn’t even try it. I very much try to integrate my debugging in with my development to save time. For instance, I have a function that checks to make sure a database call went OK. If not it sends an ajax response with the query and the error string. My calls to AJAX are always prepared to receive and display that error. Even my CSS for the page even handles displaying the returned error string in the most clear way possible. This is code I can use again and again in all my plugins, and if I didn’t reuse it I would never get anything done..
Now that I’m getting it down, it’s so nice. I love AJAX. But the more I work on the web the more I see we need a replacement for JavaScript. I mean most of the language is fine, but it needs to be a real language with the standard object oriented features implemented in the standard way: class, public, private, protected, property getters and setters, etc. The prototype keyword needs to be completely removed from the language. JavaScript and PHP need to align such that AJAX is a natural part of both languages. It’s possible, but the web is a funny thing and its technologies have a heck of a time moving forward.
Submit a Comment