Link to home
Create AccountLog in
Avatar of TRG00
TRG00

asked on

Working fine on localhost, not on server. PHP AJAX

HI
We have programmed a web application, for ordering food.
It is written in php5, javascript, mysql and implements ajax.
It works perfectly on my localhost, but if i upload it to the server and try it there it simply does not work.
I also dont know where to start looking for errors.

Address of uploaded site:
www.nutrixfoood.co.za

Any suggestions what i can try, let know if you need more info,
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

>>> We have programmed a web application, for ordering food.

You're my hero!  

Are you in Linux or Windows?  Have you seen anything interesting in your PHP error log or your web server's error log?  Does the site not come up at all, or are you getting HTTP error messages?
One of the security features that browsers implement is that the HTTP Request calls cannot be sent to a different server than the original page was served from. For example, if your page is served at "http://www.mymaindomain.com", you cannot initiate HTTP Requests to "http://www.myotherdomain.net". This is fairly straightforward, and you should be able to determine fairly easily if this is the case.

A part that is a little trickier, however, is if your page is served from 'www.mymaindomain.com', but your HTTP Request are directed to 'mymaindomain.com'. The browser considers this to be a different domain, and will block the request.

If neither of the above are the cause of the issue, use Firefox and take a look at the Javascript console (on the Tools menu). This will contain helpful debugging information if your script is generating errors.
Avatar of TRG00
TRG00

ASKER

My localhost is on windows Apache, but think to is running Linux also Apache.
The site is displaying but it is not retrieving the HTTP requests. Can it by that the server is running different version of PHP.
My URL are relative so it should not call a different server.

Here is a section of my AJAX,js

function GetFromServer(xmlRequest, targetID)
{
      url = "Control/Control_Interface.php";
      startWait(targetID)
      //alert("THE FOLLOWING REQUEST WILL NOW BE SENT TO THE SERVER:\n\n" + xmlRequest)
      var xmlHttp = new GetXmlHttpObject()
      if (xmlHttp==null)
        {
        alert ("Browser does not support HTTP Request")
        return
        }
      xmlHttp.open("POST",url,true)
      xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
      xmlHttp.setRequestHeader("Content-length", xmlRequest.length)
      xmlHttp.setRequestHeader("Connection", "close")
      xmlHttp.send("xml="+xmlRequest)      
      
      xmlHttp.onreadystatechange=function()
      {
            if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
                         {
                              //alert("THE SERVER RETURNED THE FOLLOWING RESPONSE:\n\n"+xmlHttp.responseText)
                              ParseResponse(xmlHttp.responseText)
                         }             
      }
ASKER CERTIFIED SOLUTION
Avatar of glcummins
glcummins
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of TRG00

ASKER

Thanks will check it out, we also found out that the server is running PHP 4, and we programmed in PHP 5. So think the problem is there as well.