jquery - javascript strange error, console is not giving any errors.. -


the following code, intend use bookmarklet.

javascript: (function () {        var jscode = document.createelement('script');        jscode.setattribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js');                         document.body.appendchild(jscode);     console.log("everything fine upto here!");     data = [["#txtapplcntname","test"],["#txtapplcntadd","test"]];     console.log(data);     var obj = $.parsejson(data);     (var = obj.length - 1; >= 0; i--) {         var current = obj[i];       console.log(current);         $(current[0]).val(current[1]);     };   })(); 

problems start when actions in loop never take place. gets weirder when can log variable obj , logs, when obj.length null encountered?

i experimenting on google chrome

try this:

data = '[["#txtapplcntname","test"],["#txtapplcntadd","test"]]'; 

method json.parse(str, reviver) reads string. you're trying treat ordinary array json.


Comments

Popular posts from this blog

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -