View Full Version : [Ext Core 3.0] unterminated string literal

8 May 2011, 7:05 AM
Please help me to solve this.
I write site on Ext Core and have such bug.

url: 'request/get-data.php',
success: function(response, opts){
var obj = Ext.decode(response.responseText);// Error occur here

Ajax get this text from server

{success:true,responce:{title:"3D",text:"Наконец то разобрался, вот пример (открывать в мозиле)
<a href='http://moc-081.narod.ru/data/3d/1.html'>
3d линия</a><br>.
Так же гляньте вот это <a href='http://dxdy.ru/topic25636.html'> Форум dxdy.ru</a>"}}

Error this

unterminated string literal

Help me to fix it,please.

8 May 2011, 5:22 PM
1: your client html page character code is ? and your character server code is ? if all are utf-8, will be better.
2: json parse use strictly defined will be better, { a:1 } not good, {"a":"1"} will be better

8 May 2011, 8:56 PM
The main bug was in so that from server text is sending.
And in text there are not visible '\n' '\r'

$strToEcho = "{success:true,responce:$this->response}";
$strToEcho = str_replace(array("\r", "\n"), '', $strToEcho);
echo $strToEcho;

And also I have to replace ' -caracters on " in reference

$title = str_replace(array("'"), '"', $row['title']);
$text = str_replace(array("'") , '"', $row['text']);
$this->response .="{".

Actioly I was very suprused of this non-working occasion.
I work with ExtJS from January of 2010 and I have never faced this bug.
Maybe in ExtJS it is solved.
I mean non-visual \n and \r are being replaced.
But in Ext Core not.

8 May 2011, 11:03 PM
why not to use json_encode function in PHP!!!

8 May 2011, 11:42 PM
About json_encode.
I have some problem with Russian, and also it encode all properties.
But I used to work with text in charset "windows-1251"
Now I use utf-8 maybe in it there is not such problem.
I will try.

Thanks for answer.

So I usually do like this

while($row = mysql_fetch_assoc($rs)){
$p = explode(";", $row['text']);
$field_value = explode("=", $p[$i]);
$parsed_text[strlen($parsed_text)-1]=" ";