getJSON not working correctly with codeigniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: getJSON not working correctly with codeigniter (/showthread.php?tid=57490) |
getJSON not working correctly with codeigniter - El Forum - 03-18-2013 [eluser]Unknown[/eluser] I am trying to implement AJAX call method into my website using codeigniter, the reason why i want to use AJAX so i can get live updates from the database The click button works and displays all of the JSON data but the issue is when i try and display a specific array it does not recognize it, it seems to be iterating through every single character. Things i have done to try and work it out i have alerted the datatype and found out it was a string i have managed to get ajax to work in regular PHP rather then codeigniter so their is nothing wrong with the database I have also tried to use jQuery.parseJSON so i can force it to be json but then the script did not run I used JSONlint and apprently its a valid JSON Consolelog Code: [ Controller Code: public function insertJSON() View Code: [removed] Code: [ Any help would be appreciated getJSON not working correctly with codeigniter - El Forum - 03-18-2013 [eluser]CroNiX[/eluser] I don't see you sending json headers before you output the json. I put this in a helper function... Code: function send_json($array) getJSON not working correctly with codeigniter - El Forum - 03-18-2013 [eluser]CroNiX[/eluser] Also, I think you have an extra array layer in your json. $queryresults already looks like it's an array, so this is probably also causing a problem as you wrap it all in another array: Code: $arrays = array($queryresults); Which is probably why you have a double set of brackets at that start and end ([[) and (]]) of your json output. |