Ajax vs HTML Which is better when comparing them

Ajax vs HTML Which is better when comparing them

robovrobov Posts: 31Questions: 5Answers: 0
edited July 2014 in Free community support

I am new to datatables and got it working nicely with the plenty of documentation and examples in the forum. Thank you so much for this all.

Now I am building a new site and I want to include the datatables. Basically I have the option to use an ajax load or a php load and echo the table. All my pages are created by php. So I either get the data in the php code or in a separate ajax call.

What are the pro's and cons of each ?

PHP ECHO
- probably has better seo options

AJAX
- can be easily refreshed without pageload

What are some others?
Is there a speed difference ?

Looking forward to your amazing insights.

Rob

This question has accepted answers - jump to:

Answers

  • DaimianDaimian Posts: 62Questions: 1Answers: 15
    Answer ✓

    I have been using DataTables for about 3 years now. Probably have created 50 pages using DataTables over the years.

    In short I would avoid HTML/PHP ECHO tables and always use AJAX.

    One big advantage is AJAX sourced data is much easier/faster when it comes to adding/removing/modifying columns.

  • robovrobov Posts: 31Questions: 5Answers: 0

    Thanks, and what is your opinion on the SEO and bots spidering the data ?

  • DaimianDaimian Posts: 62Questions: 1Answers: 15

    Can't comment there... all my DataTables are behind passwords.

  • allanallan Posts: 61,439Questions: 1Answers: 10,053 Site admin
    Answer ✓

    You can actually combine the two - if you DOM source the table, you can't use the built in Ajax methods of course, but you can use the rest of the API so you can make your own Ajax call to get updated data, and then use clear() and rows.add() to refresh the table.

    If you need search engines to crawl the data in your table, then really there is no choice. Use DOM data. Search engines (at least GoogleBot) do execute some Javascript, but Im not sure if that includes Ajax, and then the rendering of the data.

    One more point to consider is speed. If you have millions of rows, them a DOM sources table is going to be horribly slow since it needs to be downloaded, rendered and read back into Javascript, all on initial load.

    Personally I like Ajax (unless SEO is a priority), since as @Daimian says, it is a lot more flexible.

    So there is no hard and fast rule, it really depends upon your requirements and data!

    Allan

  • robovrobov Posts: 31Questions: 5Answers: 0

    Super...thank you so much. At least now I can make an educated choise in what to do.
    I will definately go for ajax when SEO is not important. When SEO is vital I will go for DOM

This discussion has been closed.