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,
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,
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.
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.
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,tr ue)
xmlHttp.setRequestHeader(" Content-ty pe", "application/x-www-form-ur lencoded")
xmlHttp.setRequestHeader(" Content-le ngth", xmlRequest.length)
xmlHttp.setRequestHeader(" Connection ", "close")
xmlHttp.send("xml="+xmlReq uest)
xmlHttp.onreadystatechange =function( )
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="compl ete")
{
//alert("THE SERVER RETURNED THE FOLLOWING RESPONSE:\n\n"+xmlHttp.res ponseText)
ParseResponse(xmlHttp.resp onseText)
}
}
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
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,tr
xmlHttp.setRequestHeader("
xmlHttp.setRequestHeader("
xmlHttp.setRequestHeader("
xmlHttp.send("xml="+xmlReq
xmlHttp.onreadystatechange
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="compl
{
//alert("THE SERVER RETURNED THE FOLLOWING RESPONSE:\n\n"+xmlHttp.res
ParseResponse(xmlHttp.resp
}
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
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.
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?