Parallel/Multiple ajax calls

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?

Any idea guys…?

Fortunately I have found the solution here

http://www.thedeveloperday.com/anti-asynchronous-ajax-calls-and-php-sessions/

Anyway thanks…

the site was down. any clue?

why don’t you put the second ajax in first success function, Please check whether ajax triggers too, I recommend you to use


Yii::app()->clientScript->registerScript("form_name for registration", " javascript code",  CClientScript::POS_READY or try CClientScript::POS_END)