Hi,
I'm quite new to the whole jQuery/JSON thing but thought I would give it a go. The idea is that I am posting data to a PHP script and then returning a JSON object. This works fine on my localhost but on the web server, Firebug shows that the JSON object is being returned but I also get a 404 error.
Any ideas where I could be going wrong?
Javascript -
$(".vote").click(function(){
$('#graph').empty();
var area = $(this).attr("id");
$.ajax({
dataType: "json",
type: "POST",
url: "<?php echo base_url(); ?>home/vote",
cache: false,
data: "area="+ area,
success: function(json){
arrayOfData = new Array(
[json.science_graph,'Science','#009999'],
[json.maths_graph,'Maths','#FF6600'],
[json.ict_graph,'ICT','#FF0000'],
[json.mfl_graph,'MFL','#FFCC00'],
[json.dt_graph,'Design Technology','#33CC00'],
[json.other_graph,'Other Events','#003399']
);
$('#graph').jqBarGraph({ data: arrayOfData, barSpace: 5, width: 430 });
}
});
});
PHP -
if ($vote == true)
{
$poll = $this->ts_model->graph_poll();
list($maths, $science, $ict, $dt, $mfl, $other) = $poll;
echo "{";
echo "\"science_graph\":\"".$science."\",";
echo "\"ict_graph\":\"".$ict."\",";
echo "\"dt_graph\":\"".$dt."\",";
echo "\"other_graph\":\"".$other."\",";
echo "\"mfl_graph\":\"".$mfl."\",";
echo "\"maths_graph\":\"".$maths."\"";
echo "}";
}
Thanks in advance.