ajax回调函数返回值处理时eval的有关问题苦恼人
时间:2021-07-01 10:21:17
帮助过:33人阅读
ajax回调函数返回值 处理时eval的问题 苦恼人啊
经过检测 处理成功:
var res=eval("("[{"fid":"3","sid":"3","sonName":"初一化学"},{"content":'
wwwwrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrqqq
'},{"content":'
wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww
'}]")");
经过检测处理失败(没有执行):var res=eval("("
[{"fid":"3","sid":"10","sonName":"初四化学"},{"content":'
![](https://img.gxlcms.com//Uploads-s/https://img.gxlcms.com//Uploads-s/https://img.gxlcms.com//Uploads-s/new/2019-09-21-201921/w_chuangyisheji.jpg)
'},{"content":'
dddddddddddddddddddddddddddddddddddddddddd
sdddddddddddddddddddddddd
'}]
")");
大家看看 ajax返回值的时候用eval处理 第二个为什么会不行呢?
------解决方案--------------------js 的字符串中不能有换行符,如一定要有则需转义