フランス語のコンテンツを含む列を選択した場合にのみ、このエラーが発生します。それは言語の問題かもしれません。このエラーを回避するにはどうすればよいですか?datatablesは、私がフレンチテキストからデータベースをロードしているときに無効なjson応答を返します
DataTables警告:テーブルID =例 - 無効なJSON応答。このエラーの詳細については、http://datatables.net/tn/1
$(document).ready(function() {
$('#example').DataTable({
"processing": true,
"serverSide": true,
/*"contentType": false,*/
"ajax": '<?=base_url()?>'+"posts/get_html_posts"
});
});
<table id="example" class=" ui table" cellspacing="0" width="100%">
<thead>
<tr>
<th>No</th>
<th>Category Name</th>
<th>Subcategoty Name</th>
<th>Title En</th>
<th>Title Fr</th>
<th>Is Draft</th>
<th>Edit</th>
<th>Delete</th>
<th>Website url</th>
</tr>
</thead>
</table>
コントローラ
public function get_html_posts()
{
require(APPPATH .'third_party/ssp.class.php');
$table = 'posts';
$primaryKey = 'post_id';
$columns = array(
array('db' => 'post_id','dt' => 0),
array('db' => 'category_id', 'dt' => 1),
array('db' => 'subcategory_id', 'dt' => 2),
array('db'=>'title_en','dt'=>3),
array('db'=>'title_fr','dt'=>4),
array('db' => 'is_draft','dt' => 5,"formatter"=>function($d,$row) {
if($row['is_draft']==1)
return "<spna class='ui orange label'>Draft</span>";
else
return "<spna class='ui green label'>Published</span>";
}),
array('db' => 'post_id','dt'=>6,"formatter"=>function($d,$row) {
return "<a href='".base_url()."posts/edit/".$row['post_id']."' class='ui orange button padding-10'><i class='write icon margin-0'></i></a>";
}),
array('db'=>'post_id','dt'=>7,"formatter"=>function($d,$row) {
return "<a href='#' class='ui red button padding-10' onclick='return delete_record(this.id)' id='".$row['post_id']."'><i class='remove icon margin-0'></i></a>";
}),
array('db'=>'post_slug','dt'=>8,"formatter"=>function($d,$row)
{
$web_url = "http://localhost";
return "<a class='ui orange button padding-10' target='_blank' href=".$web_url.'category/'.str_replace('-','', $row['category_id']).'/'.$row['subcategory_id'].'/'.$row['post_id'].'/'.$row['post_slug']."><i class='expand icon margin-0'></i></a>";
})
);
$sql_details = array(
'user' => 'root',
'pass' => '',
'db' => 'my_demo',
'host' => 'localhost'
);
//header('Content-Type: application/json');
echo json_encode(
SSP::simple($_GET, $sql_details, $table, $primaryKey, $columns)
);
}
ajaxの出力を共有することはできますか? – philantrovert
あなたのAJAXレスポンスの文字エンコーディングに問題があるようです。 PHPコードを表示してください。 –
私はフランス語に対処しなければならなかったときに、一重引用符がフランス語の文章で頻繁に表示されるので、一重引用符の使用にいくつかの問題がありました。 – Cashbee