Home > Web Front-end > JS Tutorial > Implementation method of dynamically generating js classes_javascript skills

Implementation method of dynamically generating js classes_javascript skills

WBOY
Release: 2016-05-16 19:16:35
Original
1194 people have browsed it

最近我在研究ajax的问题,我可以在服务器端生成一个xml文档返回给前台
由前台xmlHttp.responseXML获得xml文档
假如我生成的xml文档是如下的

   jack
   12
   

beijing

   2007/03/20


前台得到了这个文档后能否动态地生成一个类呢?这个类的代码如下
function User(){
   var name;
   var age;
   var address;
   var date;
}
并且将xml文档的数据对应地保存进User对象,各位js的高手有没有办法实现这个呢?

1.  jsObject.text=xxx
2.  eval(xxx)


[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]



[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]

如果你要构造一个类,就用eval返回类,不要返回对象就行了.

[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template