Is it possible with Javascript to dynamically generate php code and run it without reloading?
|
Well, technically, you could use ajax to send the code to backend that would then save it and another ajax call to run it but that would be a tremendous security hole, i.e. DONT DO IT |
|||
|
You have to understand something, Javascript is Client-Side language, and PHP is Server-Side, hence you can't use Javascript to "generate" PHP code. What you can do is send data through a request via POST or GET using AJAX to a PHP file, which will do something with that data and then return a response without reloading the page. |
|||||
|
Yes you can do it but it is pointless and dangerous. You can "generate" php code for some purposes /eg automated php script modification/ but you should never allow server side to directly execute unescaped input. Looking at your question I suppose you dont clearly make the difference between Client and Server sides scripting. So make sure you realize it! I suggest you think again and find better solution to your problem /or ask if you cant/. Some further information : XSS |
|||
|