Which would be a better way to load data via ajax
Posted
by
Mike
on Programmers
See other posts from Programmers
or by Mike
Published on 2012-06-12T19:56:18Z
Indexed on
2012/06/12
22:47 UTC
Read the original article
Hit count: 385
I am using google maps and returning html/lat/long from my MySQL database
Currently
- A user picks a business category e.g; "Video Production".
- an ajax call is sent to a CodeIgniter controller
- the Controller then queries the db, and returns the following data via JSON
- Lat/Long of the marker
- HTML for the popup window
- this is approximately 34 rows in the database across two tables per business
- the ajax call receives this data and then plots the marker along with the html onto the map
The data that is returned from the controller is one big json object... This is done for all businesses that exist in the Video Production category (currently approx 40 businesses). As you can see, pulling this data for multiple categories (100s of businesses) can get very very taxing on the server.
My question is
Would it be more beneficial to modify the process flow as such:
- a user picks a business category e.g; "Video Production".
- an ajax call is sent to a CodeIgniter controller
- the controller then queries the database for the location base information
- lat/long
- level (used to change marker icon color)
- This would be a single row per business with several columns
- the ajax call receives this data and then plots the marker on the map
- when the user clicks a marker an ajax call is sent to a CodeIgniter Controller
- the controller queries the database for the HTML and additional data based on business_id
and if not, what are some better suggestions to this problem?
In summary this means rather than including the HTML and additional data along for each business, only submitting minimal location information and then re-query for that information when each business marker is clicked.
Potential Downsides
- longer load times when a user clicks a marker icon
- more code??
- more queries to the database
© Programmers or respective owner