People who claim eval() is evil and bad for javascript or should be removed DO NOT and I repeat DO NOTUNDERSTANDITSPROPERUSE.
Like any tool in the tool box, it can be abused and is very often so abused by those who don’t know how to achieve a goal or have something to hide like script kiddies that obfuscate code.
I have to point out that one of the examples you give is wrong. It results in an “Uncaught ReferenceError: foo is not defined “ error notice.
As for the gentleman passing comment about “AJAX should be data”, I have to point out that anything the server sends “IS DATA” even if its binary data, its still data. If AJAX relied on binary data then you would have to have larger transcoding routines to make anything the server sends legible.
The point of sending TEXT based data is very obvious :)
People who claim eval() is evil and bad for javascript or should be removed DO NOT and I repeat DO NOT UNDERSTAND ITS PROPER USE.
Like any tool in the tool box, it can be abused and is very often so abused by those who don’t know how to achieve a goal or have something to hide like script kiddies that obfuscate code.
I have to point out that one of the examples you give is wrong. It results in an “Uncaught ReferenceError: foo is not defined “ error notice.
As for the gentleman passing comment about “AJAX should be data”, I have to point out that anything the server sends “IS DATA” even if its binary data, its still data. If AJAX relied on binary data then you would have to have larger transcoding routines to make anything the server sends legible.
The point of sending TEXT based data is very obvious :)