簡體   English   中英

使用JQuery-1.7.1.min.js的JSON解析錯誤

[英]JSON parsing error using JQuery-1.7.1.min.js

我正在將DataTable 1.7.5和JQuery-1.7.1.min.js一起使用,並獲取JSON解析錯誤。 在瀏覽幾個在線論壇時,建議升級JQuery-1.5.1.min.js的驗證器插件,但不升級JQuery-1.7.1.min.js的驗證器。是否有人對此問題有任何建議?

Table HTML:
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example" >
                    <thead>
                        <tr>
                            <th>#</th>                              
                            <th></th>
                            <th>Name</th>
                            <th>Shpr</th>
                            <th>Org</th>
                            <th>Cne</th>
                            <th>Dest</th>
                            <th>Dep Dt</th> 
                            <th>LR No</th>
                            <th>Asset No</th>
                            <th>Curr Dt</th>
                            <th>Spd km/h</th>
                            <th>Waypoint1</th>
                            <th>Waypoint2</th>
                            <th>SDA</th>
                            <th>DETA</th>   
                            <th>AMC</th>                                                        
                        </tr>
                    </thead>
                    <tbody>

                    </tbody>
</table>

Javascript:

var oTable = $('#example').dataTable({

                "aLengthMenu" : [[-1, 10, 25, 50, 100], ["All", 10, 25, 50, 100]],
                "iDisplayLength" : -1,
                "bProcessing": true,
                "bJQueryUI": true,
                "bAutoWidth": false,
                //"sScrollY": "300px",
                "sPaginationType": "full_numbers",
                "sAjaxSource": "ReportAction.do?process=home",
                "bDeferRender":true,
                "sDom": 'T<"clear"><"H"lfr>t<"F"ip>',
                "oTableTools": {
                    "sSwfPath": "<%=localrequestedURL %>media/swf/copy_csv_xls_pdf.swf"
                }       
            });

JSON數據:

result = session.createSQLQuery(sql_homepage).list();
String final_data = gson.toJson(result);
final_message = "{\"aaData\":"+final_data+"}";

1.變量sql_homepage引用對數據庫的選擇查詢。 2.將變量final_message傳遞給操作類,該操作類將數據傳遞給JSP。

我遇到了同樣的問題,它是由一個不可見的字符保存到數據庫的。 最好使用json驗證程序來查看錯誤的位置。 我使用了這個: http : //www.freeformatter.com/json-validator.html和這個http://jsonformatter.curiousconcept.com/

datatables是有關它將解析的JSON的超級finickey。 我必須100%完美,最終我需要創建一個php函數來制作JSON對象字符串,而不是僅使用php函數json_encode

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM