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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.