I thought I would take a look at learning Ajax, I’m still not completely sure what specifically defines a program to be Ajax aside from communicating and live updating client side and server side.
What did I learn from the first 11 tutorials?
index.html – When loading the web page automatically load the js in the head and call the method in the body that is used to communicate with the server running php. Add the ui elements to collect input with appropriate ids.
establish communication with server via js – 3 steps.
- Create xmlHttp object for communication – this is either an ActiveX object with IE or XMLHttpRequest() with chrome or firefox
- Create the process method that uses the xmlHttp object to communicate with the server
- Handle the server response depending on the xmlHttp readystate
I ran into a few bugs.
I’m not familiar with XML, I need to understand the response tags better.
When defining the xml version in near the top of foodstore.php there was a space in the string between UTF and -8 that was giving me a parsing error.
My page was not updating automatically, it required a page reload to register any change. Turns out this was caused by a bug in my php code within my xml response tags. The code was obviously hitting a wall but I was not getting an error, perhaps I can kick back events or exceptions.