javascript eval问题 [英] javascript eval problem

查看:61
本文介绍了javascript eval问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试将json对象转换为javascript对象但是当我(在我的文件.html中)写入相对于''eval'的行时,该页面无法正常工作并且不会t显示任何内容:

Hello, I''m trying to convert a json object into a javascript object but when I write (in my file .html) the line relative to ''eval'' the page doen''t work and don''t display anything:

展开 | 选择 < span class =codeDivider> | Wrap | 行号

推荐答案

嗨...


欢迎来到剧本...


i假设您提供了该代码作为示例...因为您的 myJSON 已经是一个JS对象了无需被证实...我认为你的字符串来自XMLHttpRequest。看看下面的例子:

hi ...

welcome to theScripts ...

i assume you provided that code as an example ... since your myJSON already is an JS-object it has no need to be evaled ... and i think your string comes from a XMLHttpRequest. Have a look at the following example:

展开 | 选择 | Wrap | 行号




和谢谢快速回复。

我有点困惑。是的我还有我的JSON对象:

var myJSON = {" count":26," value":" fdfdfddf"; ............. ....................};

和我想要做的是将该变量转换为Javascript对象(进行操作)它,但此刻我不知道如何操纵)。我正在练习....

我怎样才能正确转换它?

谢谢。


编辑:有一种方法,使用Javascript对象,在其上执行循环并打印所有值内容领域? (我在JSon中有很多标记为value的文件夹)。
Hi,
and thanks for fast reply.
I''m a bit confused. Yes I have my JSON object yet:
var myJSON = {"count":26,"value": "fdfdfddf";.................................};
and what I''m trying to do is convert that variable to a Javascript object (to manipulate it but at the moment I don''t know how manipulate). I''m doing practice....
How can I convert it properly, please?
Thanks.

is there a way, with a Javascript object, to to do a loop on it and print all "value" content fields? (I have many filelds labeled "value" in the JSon).


展开 | 选择 | Wrap | 行号


这篇关于javascript eval问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆