Jquery数据表带有特殊字符的服务器端处理(例如:äää)

时间:2014-01-30 16:17:34

标签: jquery jquery-datatables

我正在为我的应用程序使用数据表,我使用了服务器端分页[JSP-Struts-2],我在特殊字符搜索问题上经历了不同的线程..仍然我无法弄明白。常规英文文本搜索工作正常..请让我知道需要做的更改才能进行特殊字符搜索。

请在下面找到我的代码..

$(document).ready(function(){

                        oTable = $('#example').dataTable({
                            "bJQueryUI": true,
                            "bPaginate": true,
                           "bServerSide": true,
                            "sAjaxSource": "ajaxUserSearch.action",
                            "bProcessing": true,
                                     "bLengthChange": false,                               
                            "oLanguage": {
                            "sUrl": '<s:text name="datatables.msgs"/>'
                                },

                                    "aoColumnDefs": [
       {
           "aTargets":[0],

           "fnCreatedCell": function(nTd, sData, oData, iRow, iCol)
           {
               $(nTd).css('text-align', 'center');
           },
           "mData": null,
           "mRender": function( data, type, full) {    // You can use <img> as well if you want
           //console.log(full[7]);
           if(full[7]=='ACTIVE' || full[7]=='Active')
                            {
                                return '<input type="radio" name="salesOrgSelection" onclick="setUsrId('+full[9]+',2)"  /> <td>';
                            }
                            else{
                                return '<input type="radio" name="salesOrgSelection" onclick="setUsrId('+full[9]+',1)"  /> <td>';
                            }

           },

            }

    ]
                        });
                                oTable.fnSetColumnVis( 9, false );

                    });

1 个答案:

答案 0 :(得分:0)

在SERVER_processing.php中查找:

mysql_select_db( $gaSql['db'], $gaSql['link'] ) or
    die( 'Could not select database '. $gaSql['db'] );

后加入

//To send utf8 data to MySql - needed if you need to inject utf8 data for search
    mysql_query("SET character_set_client=utf8", $gaSql['link']);
    mysql_query("SET character_set_connection=utf8", $gaSql['link']);

//To read utf8 data from MySql - needed if your result set contains utf8 data
    mysql_query("SET character_set_results=utf8", $gaSql['link']);
相关问题