How to call Ajax function recursively.
        Posted  
        
            by MAS1
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by MAS1
        
        
        
        Published on 2010-04-09T07:22:59Z
        Indexed on 
            2010/04/09
            7:33 UTC
        
        
        Read the original article
        Hit count: 503
        
Hi guys, I want to know how to call Ajax function Recursively. My ajax code is like this,
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
  var step='1';
  $.ajax
  (
   {   
    url: 'test1.php',
    data: {step: step},        
    success: function(output) 
    {                                         
       step=eval(output);
       alert(step);
    }
   }
  );
</script>
</head>   
</html>
And php code is like this
<?php
 function writeName()
 {
  echo "step=2";
 }
 function ReadName()
 {
  echo "In Read Name Function";
 }
 if(isset($_REQUEST['step']) && !empty($_REQUEST['step']))
 {
  $step = $_REQUEST['step'];
  switch($step)
  {
   case '1' : 
    writeName();
    break;
   case '2' : 
    ReadName();
    break;
   default  : 
    echo "Empty String";   
  }
 }
?>
first time this function is get called with value of step variable equal to 1 and Function Write name modified it as 2. Now i want to call this Ajax function with Step variable value equal to 2. So that 2nd php function gets called.
© Stack Overflow or respective owner