Reputation: 12173
I am wondering if it is possible to use JS (jQuery) to make a $.post
from any website on any domain, to a script on my server?
The reason for this question, is because I do not want to give out my PHP files to the client (and I dont want to spend money on ionCube or the likes), so making the request to my server would not give out my source.
My prefered way would be to simply include a JS file, like
<script src="http://MySite.com/MyScript.js"></script>
and have a function in there that does the Post to my PHP script, however due to the same-origin policy, I cannot do a POST request to a remote server.
I could of course make a proxy.php and make the request to it, but I am trying to keep it in a way so the client only have to include a small snippet into their HTML code, in order to use my app.
Is there a (less painfull) way to do this?
Upvotes: 0
Views: 905
Reputation: 270637
Instead of using Javascript, why not give your client a PHP file that calls file_get_html()
against your code on your server? It would have the same effect, without worrying about the client-side Javascript.
This would function similarly to a remote PHP include, but it is executed on your server and received as HTML.
You could also use cURL in PHP to call your remote PHP script, returning the output as HTML, and parsing out the bits you need.
file_get_html()
is component of Simple HTML DOM
Upvotes: 1