L
Logos
Yes, eval is a tool of the devil and I'll burn for using it. However,
in this instance it's quite handy and I'm quite lazy.
So, here's a weird one, and I'm wondering if anyone has a workaround.
I am pulling data off a server via AJAX, and some of that data has
non-English characters in it. The data is in the form of a json:
{"exitCode":1,"className":"clientRecords"
,"strAccountId":"100"
,"strName":"Dr. Gary A. Martin"
,"intReportsPurchased":100
,"intReportsUsed":13
,"intBalance":87
,"clientData":{
"r19":{
"className":"client"
,"intId":353
,"strFname":"NameOf"
,"strLname":"Someone"
,"strMname":""
}
,"r7":{
"className":"client"
,"intId":251
,"strFname":"BananaHead"
,"strLname":"Myrbø"
,"strMname":""
}
}
For testing, I was using eval("json =" +response.text). This works
fine for any records that DON'T have a non-English character in them.
However, when it has something like 'Myrbø' with the funny o on the
end, it dies and throws an error dialog saying "Expected '}'". Why
would it choke on the funny character? If I copy and paste the json
directly into the code, it works fine; it's just when it's embedded in
the eval that it goes tits up.
For extra strangeness, this does NOT happen on IE5.5, IE7, FF1.5.x or
FF1.0.x - just on IE 6 SP2!
Has anyone ever seen suchlike before???
Tyler
in this instance it's quite handy and I'm quite lazy.
So, here's a weird one, and I'm wondering if anyone has a workaround.
I am pulling data off a server via AJAX, and some of that data has
non-English characters in it. The data is in the form of a json:
{"exitCode":1,"className":"clientRecords"
,"strAccountId":"100"
,"strName":"Dr. Gary A. Martin"
,"intReportsPurchased":100
,"intReportsUsed":13
,"intBalance":87
,"clientData":{
"r19":{
"className":"client"
,"intId":353
,"strFname":"NameOf"
,"strLname":"Someone"
,"strMname":""
}
,"r7":{
"className":"client"
,"intId":251
,"strFname":"BananaHead"
,"strLname":"Myrbø"
,"strMname":""
}
}
For testing, I was using eval("json =" +response.text). This works
fine for any records that DON'T have a non-English character in them.
However, when it has something like 'Myrbø' with the funny o on the
end, it dies and throws an error dialog saying "Expected '}'". Why
would it choke on the funny character? If I copy and paste the json
directly into the code, it works fine; it's just when it's embedded in
the eval that it goes tits up.
For extra strangeness, this does NOT happen on IE5.5, IE7, FF1.5.x or
FF1.0.x - just on IE 6 SP2!
Has anyone ever seen suchlike before???
Tyler