Dear friends
I am trying to create multiple ajax calls at the same time. Call one’s response should be received in 10 seconds and Call tow’s response should be received in one second at local. Without using Yii framework this below code works fine. But when i put it in Yii its not working. I couldn’t get response of 2nd call until first request is not completed.
<a href ="#" class="btn">Click me</a>
<div class="d1">D1: </div>
<div class="d2">D2: </div>
<script>
$(".btn").click(function(){
$.ajax
({
url: '<?php echo Yii::app()->createUrl("/settings/callOne"); ?>',
cache: false,
//data:"id="+id,
success: function(response)
{
$(".d1").append(response);
}
});
repeater();
});
function repeater()
{
$.ajax
({
url: '<?php echo Yii::app()->createUrl("/settings/callTwo"); ?>',
cache: false,
//data:"id="+id,
success: function(response)
{
$(".d2").append(response);
setTimeout("repeater()", 1000);
}
});
}
</script>
Here is my controller actions
public function actionCallOne()
{
sleep(10);
echo "Data has been saved successfully";
}
public function actionCallTwo()
{
echo "-";
}
Any idea how to solve it?