0

Hello, I am trying to get a form to call a javascript function on submit to send an ajax request. The site sits on one server and the php target file on another. I get a status of 0. From what I read, this is because the php file sits on a different server. I do don't believe I can get around the files sitting on different servers.

I can set the php file as the form action, but I do not want to redirect, just send a request to the other server to modify some values in a DB. If I can not send an ajax request between servers, I was thinking an alternative might be to set the php file as the form action, run the updates, and then have the page redirect me back. Is there a better way to get around this problem? Am I mistaken about the cause of the status 0?

Thank you for your input.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Luckychap
0

You can not send ajax request to other server. Ajax only works on same domain server.

I am not sure if it will work...But you must try this.
You can create a proxy on your server to handle external php file. Something like this:

<!-- Proxy to handle external php -->
<html>
   <body>
       <?php
           include("http://somedomain/externalPhpFile.php");
           echo "Done";
       ?>
   </body>
</html>

Say, myProxy.php
Now send ajax to this file.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.