Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I fix JSON.parse: unexpected character Line 550 jQuery.js error for jTable plugin?
    text
    copied!<p>Hi I am using php to connect to my database. Here is my list action code: the table and database do have the same name</p> <pre><code>&lt;?php try { //Open database connection $con = mysql_connect("localhost","root",""); mysql_select_db("702data", $con); //Getting records (listAction) if($_GET["action"] == "list") { //Get records from database $result = mysql_query("SELECT * FROM 702data;"); //Add all records to an array $rows = array(); while($row = mysql_fetch_assoc($result)) { $rows[] = $row; } //Return result to jTable $jTableResult = array(); $jTableResult['Result'] = "OK"; $jTableResult['Records'] = $rows; print json_encode($jTableResult); } </code></pre> <p>and here is my jtable initialization:</p> <pre><code>&lt;body&gt; &lt;div id="DeviceTableContainer"&gt;&lt;/div&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $('#DeviceTableContainer').jtable({ title: 'Wireless Monitor', actions: { listAction: 'DeviceActions.php?action=list', createAction: 'DeviceActions.php?action=create', updateAction: 'DeviceActions.php?action=update', deleteAction: 'DeviceActions.php?action=delete' }, fields: { DeviceId: { key: true, list: false }, DeviceTag: { title: 'Device Tag', width: '40%' }, PV: { title: 'PV', width: '10%' }, SV: { title: 'SV', width: '10%' }, Timestamp: { title: 'Timestamp', width: '30%', type: 'date', create: false, edit: false } } }); $('#DeviceTableContainer').jtable('load'); }); &lt;/script&gt; &lt;/body&gt; </code></pre> <p>The error I am receiving is on this line in jQuery.js:</p> <pre><code>parseJSON: function( data ) { // Attempt to parse using the native JSON parser first if ( window.JSON &amp;&amp; window.JSON.parse ) { return window.JSON.parse( data );//////////////////////////////////// } </code></pre> <p>It looks like it is parsing the entire deviceactions.php file because in firebug the data object has the entire file net to it as a string. I am very new to web dev so it could be something obvious. I am also developing this as a java web application if that matters. Thanks</p> <p>edit: here is some more information about the error</p> <pre><code>parseJSON()jquery.js (line 550) data = "&lt;?php\r\ntry\r\n{\r\n //Open ...TableResult);\r\n}\r\n \r\n?&gt;" ajaxConvert()jquery.js (line 8447) s = Object { url="DeviceActions.php?action=list", type="POST", isLocal=false, more...} response = "&lt;?php\r\ntry\r\n{\r\n //Open ...TableResult);\r\n}\r\n \r\n?&gt;" jqXHR = Object { readyState=4, responseText="&lt;?php\r\ntry\r\n{\r\n //Open ...TableResult);\r\n}\r\n \r\n?&gt;", getResponseHeader=function(), more...} isSuccess = true </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload