JQuery Eval for null JSon object
I am using Jquery's $.ajax()
method to retrieve a JSON object from a Webservice. If my data (JSON) is null or undefined, I am getting a
Microsoft JScript compilation error :
Expected ']'
error for the below line of code:
var data1 = eval("(" + msg + ")");
This works fine in VS2005 and VS2008 is this a setting in VS2010? or am I doing a开发者_运维知识库nything wrong
Not sure what this has to do with visual studio...
If you're including jQuery you might very well do
var data1 = $.parseJSON(msg);
Instead of using eval. If that still fires an error, the server response might be malformed, can you please paste it here?
Cheers!
精彩评论