1

I have a list of results Im displaying from the database using php. I query the database based on the search options the user uses and then return the results in a table layout. Im thinking about using jquery and ajax to call the php script instead so I can use something like a loading icon so they know its working instead of the page just hanging waiting for the results.

My question is, would it be faster to call the php script from jquery using ajax and have the php script get the results, build the view then return the view and have jquery just display the view from the output of the php script? Or would it be faster to request the php page from jquery/ajax, have the php script return json object of the results and just have jquery loop through it and build the view inside the jquery function instead?

John
  • 9,840
  • 26
  • 91
  • 137

1 Answers1

0

This will depend on how much markup is used to display the result. I would suspect that if you have a lot of markup, then using JavaScript to build the result would appear to load faster because you don't have to transfer the markup data and can begin displaying results earlier than if you received the whole php block.

My guess is that total time comparison will depend on implementation of your JavaScript routines. If you are using lots of DOM manipulations that will slow you down.

Levi Morrison
  • 19,116
  • 7
  • 65
  • 85
  • Morrison Its basically a table with 20 rows showing per page for pagination. I cant type today! – John Jul 01 '11 at 19:42