blackcell Posted July 7, 2008 Share Posted July 7, 2008 I am trying to get a simple ajax function to work but can't find a good example of how to write the remote script to work because it is in asp and I don't know what it does. The asp script is <% response.expires=-1 response.write(time) %> and I need to know how to do something similar in php. Thanks for any help. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted July 7, 2008 Share Posted July 7, 2008 php very remotely interacts with ajax. You need to manage most of it on the AJAX side and send it to php through methods like GET/POST and then treat it as a normal GET/POST request. Quote Link to comment Share on other sites More sharing options...
trq Posted July 7, 2008 Share Posted July 7, 2008 That code is basically the same as.... <?php header("Expires: Thu, 01 Dec 1994 16:00:00 GMT"); echo date('g:i:s'); ?> Quote Link to comment Share on other sites More sharing options...
blackcell Posted July 8, 2008 Author Share Posted July 8, 2008 Then I am doing something else with the ajax.... index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> function ajaxFunction() { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); //alert("Firefox"); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); //alert("IE"); } catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); //alert("?"); } catch (e) { //alert("Your browser does not support AJAX!"); return false; } } } } xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { document.myForm.time.value=xmlHttp.responseText; } xmlHttp.open("GET","ajaxfunction.php",true); xmlHttp.send(null); } </script> </head> <body> <form name="myForm"> Name: <input type="text" onkeyup="ajaxFunction();" name="username" /> Time: <input type="text" name="time" /> </form> </body> </html> ajaxfunction.php <?php header("Expires: Thu, 01 Dec 1994 16:00:00 GMT"); echo date('g:i:s'); ?> Quote Link to comment Share on other sites More sharing options...
trq Posted July 8, 2008 Share Posted July 8, 2008 And your question is? Quote Link to comment Share on other sites More sharing options...
blackcell Posted July 9, 2008 Author Share Posted July 9, 2008 Of course I am sorry... Question: Does anybody see where I may be messing this up? Quote Link to comment Share on other sites More sharing options...
trq Posted July 9, 2008 Share Posted July 9, 2008 You might want to actually describe the problem. Quote Link to comment Share on other sites More sharing options...
blackcell Posted July 9, 2008 Author Share Posted July 9, 2008 All the matters pertaining to ajax that I have encountered don't usually provide good errors to troubleshoot. Just me. All I know if that it isn't working and I have copied the code from the example that worked and tried to re-write the asp script to php and it didn't work but did not give me any errors. You know what thorpe, it's not that big of a deal, i will "SOLVE" the topic to shut the thread down. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.