Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
162
rated 0 times [  169] [ 7]  / answers: 1 / hits: 26971  / 13 Years ago, mon, august 15, 2011, 12:00:00

How do I write PHP within Javascript so that I can load files? Or is there a better way?
(I am loading text files from the server... so I need to use PHP to load those files. I don't know how to handle call backs in PHP but I can do it in Javascript. And from there if I can do some PHP from within the Javascript, I can solve my problem.)



thx



desired sequence:
SaveButton
LoadButton
When the load button is pressed, load a textfile from the server into a textbox.
When the save button is pressed, save the textbox text to the server.

More From » php

 Answers
8

You may use PHP to create a file that would be used as a JavaScript source.



<script type=text/javascript src=/my/js/file.php></script>


or



<script type=text/javascript>
var str = '<?php echo 1+1;?>';
</script>


PHP is serverside. JavaScript is clientside. So you cannot execute either language in the wrong platform.


[#90601] Saturday, August 13, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
stacie

Total Points: 476
Total Questions: 92
Total Answers: 102

Location: Bosnia and Herzegovina
Member since Tue, Mar 29, 2022
2 Years ago
stacie questions
Fri, Jun 26, 20, 00:00, 4 Years ago
Thu, Jan 23, 20, 00:00, 4 Years ago
Fri, Aug 30, 19, 00:00, 5 Years ago
Fri, Aug 2, 19, 00:00, 5 Years ago
;