weixin_33681778 2013-10-21 16:18 采纳率: 0%
浏览 13

jQuery和评估

First of all, lets say I have about 10 divs that are hidden and have the ID's as "modal1", "modal2", "modal3", etc... Using an ajax request, the data returned contains an ID number, lets say it is 7.

In previous tasks, I have used the javascript eval function but this does not work. I wish to append the received data to the correct modal div.

var newdataobj = JSON.parse(newdata);
var ResponseDiv = "#modal" + newdataobj.ID;
$(eval(ResponseDiv)).append(newdataobj.DataToAdd);

This doesn't work and the script stops working at this point. I have also tries using the JQuery version of eval, but that did not work either.

  • 写回答

2条回答 默认 最新

  • weixin_33696106 2013-10-21 16:19
    关注

    ResponseDiv is already a string containing exactly what you want.
    You don't want eval at all.

    评论

报告相同问题?

悬赏问题

  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 vue2登录调用后端接口如何实现