I don't have much ajax experience, maybe someone here can help.
I'm working on a script that relies on data from a query to build a bar graph. Everything is working fine, but my kludgy solution makes me shudder a bit. I'm currently making an ajax call to a php script where I pass in the SQL. The PHP queries the database, does some processing with the returned data, and outputs a response that looks something like this...
Code:
//php
the_output = "[3, 'a', '#000000'], [6, 'b' , '#111111'], [9, 'c' , '#222222']";
When it returns to the js, I use eval to process this into an array that the bar graph plugin uses.
Code:
//js
success: function(return_value){
the_array = eval('new Array(' + return_value + ')');
This works... but it's so ugly I have to believe there's a better way to pass the data between php and the js script (?)
I do need the ajax functionality so I can dynamically load different data sets without reloading the page. Just thought I would mention that, I'm not just using ajax for the sake of using it.
Thanks for any insights...