jquery - Javascript string as closure function -


i generating highcharts json using server-side technology php.

from browser sending ajax request fetch complete highcharts json , rendering it.

for e.g ajax response

    [    {       "plotoptions":{          "enabled":false,          "series":{             "stacking":"",             "point":{                "events":{                   "click":"function(e){console.log(e.point.config); console.log(e.point.category)}"                }             }          }       },       "chart":{          "type":"column",          "renderto":"lefttopcontainer",          "polar":false       },       "series":[          {             "name":"netpos",             "data":[6700,8200,11500]          }       ],       "title":{          "text":"future financial commitments-5y yr view"       },       "xaxis":{          "categories":["2010","2011","2012"]       }    } ];  

after getting server side response i'm rendering using following code

new highcharts.chart(responsedata); 

everything working fine except events

    "events":{     "click":"function(e){console.log(e.point.config); console.log(e.point.category)}"                } 

as can see in json response getting function in double quotes(" "),

my problems are

  1. since string cannot call function.

  2. if remove (" ") in php jquery ajax throws error "invalid json or parse error"

  3. i not allowed use eval() not programming practice.

is there way can iterate on json object , convert string in function called automatically.

what want eval() use it. want execute unknown code sent server. no matter approach try, @ end same eval() do.

if sure, code sent okay, there's no harm in using it.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -