[Javascript] DOM vs AJAX
M
lists at gazelasport.sk
Wed Jun 21 03:12:51 CDT 2006
Michael Borchers wrote:
>> On 6/20/06, Mike Dougherty <mdougherty at pbp.com> wrote:
>>
>>> Obviously there are correct uses for AJAX. It allows cool things to
>>> be done in a browser that
>>> were simply not possible before. None of the HowTo I have seen about
>>> AJAX discuss when NOT to use
>>> it.
>>
>>
>> There's a pretty good treatment of when not to use AJAX in this book,
>> chapter 11:
>>
>> http://www.amazon.com/gp/product/076459723X/
>
>
> indeed i work with php. so regarding adding content when working with mysql
> and other php solutions there is no other way than AJAX / web 2.0 / ... .
>
> to bring it back to the basic idea of my post:
>
> index.htm f.e.:
> <a href="...">add content</a>
> <div id="newContent"></div>
>
> let's say the new content will be a <table>.
> 1. the link now could call a javascript function that creates this table
> by createElement(...) (what i like to call DOM:) )
> 2. the link could call a XMLHttpRequest, which returns the table that
> has been stored in a seperate file (what i call AJAX:) )
>
> i see the advantage in solution 2 because it's pretty easy to change the
> table, its layout whatever.
> you could even use a normal HTML editor to do that, but if you aren't
> that familiar with DOM,
> it would take me some time with the function.
>
> now which one do you prefer and what are the actual (dis-)advantages?!
Those are 2 completely different things, in fact you can use both AJAX
and DOM.
The questions might be:
Should I send all necessery content in one request (hidden html
elements, javascript...) or send it only when it's required (AJAX)?
and
Should I create new html elemets using DOM or innerHTML?
Now which question are you asking?
More information about the Javascript
mailing list