RE: php ajax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eric, could I suggest using Prototype (http://www.prototypejs.org/) instead
of your own code.

It's very easy to use, like this :-


<script src="prototype.js"></script>
<script>
function update_content() {
	new Ajax.Updater('dynamic', 'ajaxtest.php',
			{ method: 'post', parameters: { task: 'details' } });

}
</script>



The full PHP script would look like this :-


<?php
if (@$_POST['task'] == "details") {
	echo "This is some text returned from the PHP engine via AJAX";
	exit;
}

?>

<html>

<head>
<title>Ajax Test</title>
<script src="prototype.js"></script>

<script>

function update_content() {
	new Ajax.Updater('dynamic', 'ajaxtest.php', { method: 'post',
parameters: { task: 'details' } }); 
}
</script>
</head>

<body>

<table border="1" width="100%">
  <tr>
    <td width="33%" onclick="update_content()"><a href="#">Update
content</a></td>
    <td width="33%">&nbsp;</td>
    <td width="34%">&nbsp;</td>
  </tr>
  <tr>
    <td width="33%">&nbsp;</td>
    <td width="33%"><div id="dynamic">I am going to put some content
here</div></td>
    <td width="34%">&nbsp;</td>
  </tr>
  <tr>
    <td width="33%">&nbsp;</td>
    <td width="33%">&nbsp;</td>
    <td width="34%">&nbsp;</td>
  </tr>
</table>

</body>

</html>




Robert.

-----Original Message-----
From: php-objects@xxxxxxxxxxxxxxx [mailto:php-objects@xxxxxxxxxxxxxxx] On
Behalf Of Jaldip Upadhyay
Sent: 20 March 2007 03:18
To: php-objects@xxxxxxxxxxxxxxx
Subject: Re:  php ajax

Hi Eric,
  
  You have created Javascript(Ajax) functions but you have not made call for
that code I guess.
  You should have called the functions from your html part like
onload(load******)
  or onclick(load******)
  
  Thanks

eric amougou <americkfr@xxxxxxxx> wrote:
Hello,
  could anybody tell me what s  wrong with my php ajax scripts. 
  they don  t give any result in the section they should be fullfilling. I
haven  t yet found what is not going round.
  I m working on wimdows XP ,  php5.1.6 and  apache 2.0.59
   
  Thanks in advance,
  Akoa
   
   
   
   
   
  var xmlHttp
  
  function loadFragmentInToElement(fragment_url, element_id) {
  xmlHttp=GetXmlHttpObject()
  if (xmlHttp==null)
   {
   alert ("Browser does not support HTTP Request")
   return
   } 
      var element = document.getElementById(element_id);
      element.innerHTML = '<p><em>Loading ...</em></p>';
      xmlhttp.open("GET", fragment_url);
      xmlhttp.onreadystatechange = function() {
          if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
              element.innerHTML = xmlhttp.responseText;
          }
      }
      xmlhttp.send(null);
  }
  
  function GetXmlHttpObject()
  {
  var xmlHttp=null;
  try
   {
   // Firefox, Opera 8.0+, Safari
   xmlHttp=new XMLHttpRequest();
   }
  catch (e)
   {
   //Internet Explorer
   try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
   catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
   }
  return xmlHttp;
  }
   
   
  <?php
  /******************************************************/
  $iditem=$_GET["iditem"];
  $con = mysql_connect('localhost', 'anonym', '');
  if (!$con)
   {
   die('Could not connect: ' . mysql_error());
   }
  mysql_select_db("rentalsystem", $con);
  //$sql="SELECT prop_name, value  FROM rs_prop_type pt join rs_item_property
ip ON pt.prop_id=ip.prop_id WHERE ip.item_id = '$iditem'";
  $sql="SELECT prop_id FROM rs_prop_type limit 1";
  $result = mysql_query($sql);
  
  echo "<table border='1'>
  <tr>
  <th>prop_name</th>
  <th>value</th>
  </tr>";
  while($row = mysql_fetch_array($result))
   {
   /*echo "<tr>";
   echo "<td>" . $row['prop_name'] . "</td>";
   echo "<td>" . $row['value'] . "</td>";
   echo "</tr>"; */
   echo "<tr>";
   echo "<td>" . $row['prop_id'] . "</td>";
   echo "<td>" . $row['prop_id'] . "</td>";
   echo "</tr>";
   }
  echo "</table>";
  mysql_close($con);
  ?>
   

***********************************************************************************
Any opinions expressed in email are those of the individual and not necessarily those of the company. This email and any files transmitted with it are confidential and solely for the use of the intended recipient 
or entity to who they are addressed. It may contain material protected by attorney-client privilege. If you are not the intended recipient, or a person responsible for delivering to the intended recipient, be advised that you have received this email in error and that any use is strictly prohibited.

Random House Group + 44 (0) 20 7840 8400
http://www.randomhouse.co.uk
http://www.booksattransworld.co.uk 
http://www.kidsatrandomhouse.co.uk
Generic email address - enquiries@xxxxxxxxxxxxxxxxx

Name & Registered Office:
THE RANDOM HOUSE GROUP LIMITED
20 VAUXHALL BRIDGE ROAD
LONDON
SW1V 2SA
Random House Group Ltd is registered in the United Kingdom with company No. 00954009, VAT number 102838980
***********************************************************************************


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux