namiagrigosiz
New Member
How do I define a variable in javascript with echo function, from the external php file?We have theconfigfile.php, thejsfile.js and thephpfile.php.In theconfigfile.php we have:\[code\]<?php$path = 'http://example.com/home.php'; // Set your path?>\[/code\]In thejsfile.js we have:\[code\]... if (confirm("Are you sure you want to delete")) { $.ajax({ type: "POST", url: "http://example.com/home.php", data: dataString, cache: false });...\[/code\]And in thephpfile.php we have:\[code\] <php include "theconfigfile.php"; ?> <html> <head> <script type="text/javascript" src="http://stackoverflow.com/questions/13734338/thejsfile.js"></script> </head><body>...here is the code that uses file thejsfile.js...</body></html>\[/code\]I used this method:\[code\]... if (confirm("Are you sure you want to delete")) { $.ajax({ type: "POST", url: "<?php echo $path; ?>", data: dataString, cache: false });...\[/code\]Only works when javascript is part of the code. And if I use it external, like this...\[code\]<script type="text/javascript" src="http://stackoverflow.com/questions/13734338/thejsfile.js"></script>\[/code\]...does not work! Solutions?