开发者

eval responseText/responseXML performance

开发者 https://www.devze.com 2023-01-15 04:13 出处:网络
Does anyone readily know if using eval() and responseText开发者_如何学运维 (using JSON) is faster or slower than just using responseXML?

Does anyone readily know if using eval() and responseText开发者_如何学运维 (using JSON) is faster or slower than just using responseXML?

I would imagine avoiding the eval() and using responseXML instead would be faster, despite the fact that you gotta write really long code to actually get the values of the XML.

Thanks.


Actually JSON data are most of the time smaller than XML.

It is better to not use eval() because it is a well known security leak. But I've heard of regular expression which can check the JSON compliance.

I do not like XML so I avoid it, but I suppose that the responseXML will build a DOM model which is much more heavier than the native javascript objects created by responseText

I you want to minimize the bandwidth JSON is probably a better choice than XML.


Use JSON and use a parser instead of eval. Here's one - https://github.com/douglascrockford/JSON-js

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号