php - Prototype Ajax.Updater Eval Javascript Functions and HTML -


i want inject myscript.php code handler page. here source:

handler.php

 var myarr = array(); function myfunc(){  // code  handlearray(myarr); }  function handlearray(arr){   // code  }  $("container").observe('click', function(evt){       new ajax.request('myscript.php', {          method:'get',          evalscripts: 'true',          onfailure: function(e){             console.log(e);          },          onsuccess: function(t){             $("container").update(t);             myfunc(arr);          }       });   }); 

myscript.php

<script type="text/javascript">
var myarr = array("hello", "world");
</script>
<div id="abc">some html code</html>

basically have functions defined in handler page, , myscript.php holds necessary data handler page handle. while above make ajax request myscript.php, returned code not evaluated. shows object object instead of treating html. ported same code jquery , set datatype:"script", works fine. while switching jquery not option me since entire code base built on top of prototype, love know how can have prototype treat returned page script.

i noticed there similar thread prototype ajax.updater eval javascript functions says wrapping function anonymous function , turning on evaljs flag solve problem, doesn't seem workaround in case have couple of variables , functions declared, have no idea how make of them anonymous. appreciated , let me know if need more info.

the evaluated script blocks processed in scope of ajax functions, so...

var myarr = array("hello", "world"); 

becomes local variable in function only. unavailable , discarded moments later. make returned script (myscript.php) update global myarr instead.

myarr = array("hello", "world"); 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -