How to call Ajax function recursively.
- by MAS1
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.