A little confusion about AJAX and inserting into DOM..

Posted by Gnee on Stack Overflow See other posts from Stack Overflow or by Gnee
Published on 2010-03-15T20:23:39Z Indexed on 2010/03/15 20:39 UTC
Read the original article Hit count: 297

Filed under:
|
|
|

I have this working great, but I'd like a deeper understanding of what is actually going on behind the scenes.

I am using Jquery's Ajax method to pull 5 blog posts (returning only the title and first photo). A PHP script grabs the blog posts' title and first photo and sticks it in an array and sends it back to my browser as JSON.

Upon receiving the JSON object, Jquery grabs the first member of the JSON object and displays it's title and photo. In a gallery I made, using buttons – the user can iterate the 1-5 posts.

So the actual AJAX call happens right away, and only once. I am basically using this kind of setup: $('my_div').html(json_obj[i]) and each click does a i++.

So jquery is plucking these blog posts from my computers memory, my web browsers cache, or some kind of cache in the Javascript engine?

One of the things it's returning is a pretty gnarly animated gif. I just wonder if it constantly running in the background (but not visible), stealing processing cycles...etc. Or Javascript just inserting (say a flash movie) into the DOM, but before hand does nothing but take up a little memory (no processing).

Anyway, I'm just curious. If someone is a guru on this, I'd love to hear your take. THanks!!

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about JSON