javascript - cannot access property - JS Error Shown -
this question has answer here:
my code access property:
var myarray = [{"td_stlmnt":"nn2015227","heading":"nn2015227[02/12/2015]","td_scripcd":"514286","order#":"1000000003042299","trade#":"1124070","time":"14:40:38","security":"ashimasyn (514286)","buy":"250","sell":"0","market rate":"12.90","brokerage":"12.50","buy value":"3237.5000","sell value":".0000","_":"","ordr":"ashimasynb","bdate":"20151202","net value":""},{"td_stlmnt":"nn2015227","heading":"nn2015227[02/12/2015]","td_scripcd":"514286","order#":"1000000003042299","trade#":"1124072","time":"14:40:38","security":"ashimasyn (514286)","buy":"250","sell":"0","market rate":"12.90","brokerage":"12.50","buy value":"3237.5000","sell value":".0000","_":"","ordr":"ashimasynb","bdate":"20151202","net value":""}]; alert(myarray[2].order# );
<html> <body> </body> </html>
getting js error uncaught syntaxerror: unexpected string ->on alert - when code .order# , if use .order value undefined. possible solution ??
you have use bracket notation : json[2]['order#']
you can't use #
out of string
var myarray = [{"td_stlmnt":"nn2015227","heading":"nn2015227[02/12/2015]","td_scripcd":"514286","order#":"1000000003042299","trade#":"1124070","time":"14:40:38","security":"ashimasyn (514286)","buy":"250","sell":"0","market rate":"12.90","brokerage":"12.50","buy value":"3237.5000","sell value":".0000","_":"","ordr":"ashimasynb","bdate":"20151202","net value":""},{"td_stlmnt":"nn2015227","heading":"nn2015227[02/12/2015]","td_scripcd":"514286","order#":"1000000003042299","trade#":"1124072","time":"14:40:38","security":"ashimasyn (514286)","buy":"250","sell":"0","market rate":"12.90","brokerage":"12.50","buy value":"3237.5000","sell value":".0000","_":"","ordr":"ashimasynb","bdate":"20151202","net value":""}]; document.write(myarray[1]['order#']);
Comments
Post a Comment