JSON & JQuery
This week i’ve been experimenting with some complex AJAX code for a client.
Rather than use innerHTML to replace the data in a named div. I thought that I should use the DOM creation stuff properly.
The data that I wanted to return from the database, was basically an associative array of buildings, this included a name and an id of the building in the database.
This lead me towards the fun that is JSON.
Previously I had dismissed JSON and didn’t fully understand what it’s purpose is and how it would benefit me.
That certainly changed this week. Json is very cool. To further aid my understanding of how it all works, I put together a simple AJAX call and worked out how to handle the returned JSON data. Although this was hard to begin with, I worked it out and got the project working. Later on I needed to do something similar, so I choose JSON again. This time however I was going to use JQuery (this is what we use at work).
Now I hoped that using JQuery would make things easier (it normally does). I was wrong this time :(. It seems to of made things more complicated and now I am more confused than ever. I did get it working using JQuery. I believe the documentation at the JQuery site was to blame, sometimes their examples aren’t always clear.
ah well, i’m sure I will become proficient soon, and I will be able to post up my comparison implementations. Until then, make sure you read all the docs before jumping in and coding for a client.
some point this week I will have a go at coding up a facebook app, that will interact with one of my websites. Should be fun :)
No work has been done on project GMG either :( must move ahead!