0

I get French characters who look like this é but are ç for example. I am using jQuery Ajax and making a DataTable with PHP (Code-Igniter), fetch data from database and then make json_encode datastring for DataTable, it gives error “Invalid JSON response”. I have try many things but nothing seems to get rid of the problem and I know it's because of json_encode because if i make a simple table using PHP (Code-Igniter) everything works fine.

controller.php query...; foreach ($ListOfAirport as $airport): $slot_time_a2 = array(); foreach ($Session2timeing as $s2): $sql = "SELECTcol1,col2,col3... FROMtable1LEFT JOIN table2 ONtable2.table2_id=table1.table1_idWHEREsome cluse`"; $result2 = $this->common->CustomQueryROw($sql);

           some conditions....

        endforeach;
 $dataarray[] = array('<b>' . $airport['airport_name'] . '</b>', $slot_time_a2[0], $slot_time_a2[1], $slot_time_a2[2], $slot_time_a2[3], $slot_time_a2[4], $slot_time_a2[5], $slot_time_a2[6]);
    endforeach;
    echo '{';
    echo '"draw": ' . $_GET['draw'] . ',
                "recordsTotal": ' . $this->outputData['totalrecord'] . ',
                "recordsFiltered": ' . $this->outputData['totalrecord'] . ',';
    echo '"data":';
    echo json_encode($dataarray);
    echo "}";

Before this ‘ç’ French character everything working well but after the insertion of this character in database, DataTable gives error “Invalid JSON response”.

  • I would suggest posting some of your code and telling us exactly what you've tried. – Ageonix Feb 18 '16 at 15:06
  • That's not what I meant. You should always post code in your question, never in comments. No one can read it here. Just edit your question and paste the code there, and be sure to format it as code. – Ageonix Feb 18 '16 at 16:01
  • @Ageonix please see this now. – Muzamel Saleem Feb 18 '16 at 16:18
  • Possible duplicate of [json\_encode function: special characters](http://stackoverflow.com/questions/20694317/json-encode-function-special-characters) – Ageonix Feb 18 '16 at 17:01
  • This has been answered in a few other posts already, but basically PHP requires all data be encoded as UTF-8. – Ageonix Feb 18 '16 at 17:02
  • No duplication of any Data. Error occurs when French words added in DataTable’s json_encode datastring. – Muzamel Saleem Feb 18 '16 at 17:08
  • I read many post on different sites and also implement those configurations but issue still as it is. Please share any idea to add French words in DataTable. – Muzamel Saleem Feb 18 '16 at 17:10

0 Answers0