I'm using Ajax calls to get some variables data from the DB. some of my data stored on the database contains double quotes (").
when I'm trying to display the variable :
value="'+ucontent+'"
the string gets cut in the middle (of course)
I have tried using escape() but im getting a non readable result - something with %4%2 etc...
how can i escape the double quotes in the variable and still keep a readable string... BTW - I'm using UTF8 characters.
Depends on what language in server side you are using.
If it is php, then use json_encode
to encode the response string.
If it is ruby(rails), then use escape_javascript
to escape the response string.
decodeURIComponent()
might be helpful
what escape actually does is replace some characters with a hexadecimal escape sequence. That is the reason why you are getting unreadable string like %4%2.
你可以用\\"
,如果你不使用的编码器。参见本 。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.