title: add function received by ajax to object
body: <p>I need to receive some mixed objects by ajax json and put them into a Global_obj
  I can't use $.extend() because some items are javascript functions.</p>
  
  <p>Someone know another (better) way to do this?</p>
  
  <pre><code>&lt;?php
  $ajax_response = [
      "Obj_1" =&gt; [
          "key1_1" =&gt; "function(){console.log('ok key1_1')}",
          "key1_2" =&gt; "&lt;div&gt;Something key1_2&lt;/div&gt;"
      ],
      "Obj_2" =&gt; [
          "key2_1" =&gt; "function(){console.log('ok key2_1')}",
          "key2_2" =&gt; "&lt;div&gt;Something key2_2&lt;/div&gt;"
      ]   
  ];
  </code></pre>
  
  <p>?></p>
  
  <pre><code>&lt;script&gt;
  
  var Global_obj = {};
  
  var ajax_response = &lt;?php echo json_encode($ajax_response); ?&gt;;
  
  $.each(ajax_response,function(key){
  
      Global_obj[key] = {};
  
      $.each(this,function(subkey){
          if(this.indexOf('function') &gt; -1){
              Global_obj[key][subkey] = eval( '('+this+ ')' );
          }else{
              Global_obj[key][subkey] = ''+this;
          }
      });
  });
  
  Global_obj.Obj_1.key1_1(); // show "ok key1_1"
  </code></pre>
  
  <p></p>
  
  <p>EDITED: I have edited mi old question because marked as duplicate</p>
  
  <p>So the edited question is:
  Someone know another (better) way to do this?</p>
  
  <p>Thanks</p>