Note that there are some explanatory texts on larger screens.

plurals
  1. POUncaught SyntaxError: Unexpected identifier and eval alternatives
    text
    copied!<p>I have a function which is not working correctly on all hosting environments. The returned data is in JSON format. I think the problem is with eval(). Can I use any alternative for eval(). Please help me debug this or suggest any alternative approach.</p> <p><strong>For three days, I am scrathing my head with this error (which appears only on few hostings but works fine on others)</strong></p> <p>The data inLoad.php is as</p> <pre><code>while($row=mysqli_fetch_array($sql)){ $text=$row['mesg']; $fro=$row['fro']; $tocomr=$row['tocom']; $last_msg_id_db=$row_m['maxid']; $response=array(); //$response['msg']=$table; $response['msg']=$text; $response['last_msg_id_db']=$last_msg_id_db; $final_response[]=$response; } echo json_encode($final_response); </code></pre> <p>AND the data is returned as</p> <pre><code> [{"msg":"hi&lt;br&gt;","last_msg_id_db":"173"}] main.php:96 main.php:96 [{"msg":"heloo&lt;br&gt;","last_msg_id_db":"174"}] </code></pre> <p>THe jquery function is as follows.</p> <pre><code>function chat_com_one(id, name) { $('#chatcom').show('fast'); (function chatcom_load_one(id, name) { $.ajax({ type:"Post", url:"load.php", data:{ tocom:id, last_msg_id:last_msg_id }, success:function(data) { var json = eval(data); $.each(json, function(i, row) { $("#commidwin").append(row['msg']); last_msg_id = row['last_msg_id_db']; }); setTimeout(chatcom_load_one(id, name), 500); }, error:function(XMLhttprequest, textstatus, errorthrown) { alert("error:" + textstatus + "(" + errorthrown + ")"); } }); }(id, name)); } </code></pre> <p>The below error is given in Chrome's log</p> <pre><code>Uncaught SyntaxError: Unexpected identifier main.php:95 $.ajax.success main.php:95 fire jquery.min.js:974 self.fireWith jquery.min.js:1082 done jquery.min.js:7788 callback </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