using a php file in a javascript tag on IIS server
wondering if it's possible to use a remote php file in a script tag on a server that does not have PHP installed (IIS)
The header in the php file will be set to javascript I开发者_如何学JAVA know it's possible on an apache server, but I don't have access to a windows server to test it.
<script type='text/javascript' src='http://remoteserver.com/example.php'></script>
Yes, you will be able to call the PHP file as the JavaScript source. IIS will never see the PHP. The script will be executed on the remote server that has PHP installed, and that server will output JavaScript that will be returned to the browser.
There's no reason why this shouldn't work but you'd make it even smoother by simply modifying the server with PHP installed so that it rewrites the URL for the script eg:
http://remoteserver.com/Process/example.js
would get rewritten to:
http://remoteserver.com/example.php
or similar - that way it would be indistinguishable from a client perspective.
精彩评论