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
精彩评论