I want to assign a smarty array to Javascript array
I used the following code

<script type="text/javascript">

var arr = {/literal}{$a.ins_status|@json_encode}{literal}; 


But the arrray is showing as Null

this is wrong

var arr = {/literal}{$a.ins_status|@json_encode}{literal};

it should be written as

var arr = {literal}{$a.ins_status|@json_encode}{/literal};

Whatever you want to pass to the template file, it is highly recommended to pass it from the business logic side rather going for the literal.

Besides you can always register you own plugin if that is needed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.