Jump to content

Equivalent ASP script in PHP


blackcell

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/113619-equivalent-asp-script-in-php/
Share on other sites

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');
?>

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.