如何使用ajax服务将gujarati或hindi数据从php转换为javascript

时间:2017-01-14 21:24:57

标签: javascript php ajax datatable datatables

我想使用DataTable.js API向表中显示hindi或gujarati数据。 我有以下javascript代码:

$(document).ready(function(){
  // On page load: datatable
  var url = "<?php echo base_url();?>list?job=get_companies";
  var table_companies = $('#table_companies').dataTable({
    "ajax": url,
    "lang": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Gujarati.json",
    "language": {
                "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Gujarati.json"
            },
    "columns": [
      { "data": "id" },
      { "data": "text",   "sClass": "Text" },
      { "data": "userid" }

    ],
    "aoColumnDefs": [
      { "bSortable": false, "aTargets": [-1] }
    ],
    "lengthMenu": [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]],
    "oLanguage": {
      "oPaginate": {
        "sFirst":       " ",
        "sPrevious":    " ",
        "sNext":        " ",
        "sLast":        " ",
      },
      "sLengthMenu":    "Records per page: _MENU_",
      "sInfo":          "Total of _TOTAL_ records (showing _START_ to _END_)",
      "sInfoFiltered":  "(filtered from _MAX_ total records)"
    }
  });
  });

然后我得到了来自php文件的响应看起来像(数组有三个参数,数据有hindi或Gujarati数据格式的字符串,如何使用dataTable.js设置数据):

$data = array(
              "result"  => $result,
              "message" => $message,
              "data"    => $mysql_data
            );

            // Convert PHP array to JSON array
            $json_data = json_encode($data);
            print $json_data;

0 个答案:

没有答案