Hugo Silva
Hugo Silva

Reputation: 352

view not refreshing after zend redirect

so what i am trying to do, is after the user submit some information, i make a call to a action call saveronda, to save the information on the database, after saving i want to redirect to another page, according to the firebug the html is correct, but the view isnt refreshing. so here is the code so in my /rondas/chooseronda ive got this

<span class="st-labeltext">Tags da ronda:</span>



    <table id="toolbar2"></table>
    <div id="ptoolbar2"></div>


<div class="clear" style="z-index: 670;"></div>
</div>  

<div class="st-form-line" style="z-index: 680;">
<span class="st-labeltext">Nome da ronda:</span>

   <input type="text" name="nomeronda" id="nomeronda">




<div class="clear" style="z-index: 670;"></div>
</div>     
 <div class="st-form-line" style="z-index: 680;">
<span class="st-labeltext">Tag Inicial:</span>


<select id="tagini"  name="tagini">  
</select> 
<div class="clear" style="z-index: 670;"></div>
</div>
 <div class="st-form-line" style="z-index: 680;">
<span class="st-labeltext">Tag Final:</span>


<select id="tagfim"  name="tagfim">  
</select> 
<div class="clear" style="z-index: 670;"></div>
</div> 
 <div class="st-form-line" style="z-index: 680;">
<span class="st-labeltext">Ordem:</span>


<select id="ordem"  name="ordem">
    <option value="Sim">Sim</option>
    <option value="Não">Não</option>
</select> 
<div class="clear" style="z-index: 670;"></div>
</div> 
<div class="button-box" style="z-index: 460;">
<input id="button" class="st-button" type="submit" value="Submit" name="button">
<input id="button2" class="st-clear" type="reset" value="Cancel" name="button">
</div>

when the user press the button submit i am making an ajax call to /rondas/saveronda and send some data, here is the code:

<script language = "Javascript">
    $(document).ready(function() {
    $("#button").click(function () {



                     /*
       $.ajax({
       url: '/rondas/saveronda',
       type: 'POST',
       data: {param1: param1, param2:param2 },
       datatype: "json"
       */
       //buscar o nome
       /*var nomeronda=$("#nomeronda").val();
       //buscar a ordem
       var ordem=$("#ordem").val();

       //tag inicial e tag final
       var taginicial=$("#tagini").val();
       var tagfinal=$("#tagfim").val();
       if(taginicial==tagfinal)
           {
               alert("a tag inicial não pode ser a mesma que a tag final");
           }
           else
               {
                   var tags="";
                   //var allRowsOnCurrentPage = $('#toolbar2').getDataIDs();
                   var ids = $("#toolbar2").jqGrid('getDataIDs');

                    for (var i = 0; i < ids.length; i++) 
                    {
                        var rowId = ids[i];
                        var rowData = $('#toolbar2').jqGrid ('getRowData', rowId);
                          tags=tags+rowData.id_tag.toString()+' ';



                    }*/

                $.ajax({
                            url: '/rondas/saveronda',
                            type: 'POST',
                            data: {param1: "sasa"},
                            datatype: "json"

                    });
               //}


    }); 
});

</script>

in this case i am sending param1 with the value "sasa", and through firebug i am detecting the post to the /rondas/saveronda. after saving the data i want to redirect the user to /rondas/list, so i have been trying different solution

public function saverondaAction()
    {
        // action body

        /*  
             if($this->_request->isXmlHttpRequest())
        {


        $param1 = $this->_request->getParam('param1');
        $param2 = $this->_request->getParam('param2');
        $param3 = $this->_request->getParam('param3');
        $param4 = $this->_request->getParam('param4');
        $param5 = $this->_request->getParam('param5');
        $rondasModel= new Application_Model_Ronda();


                    $this->_forward('list', 'rondas');





             }
         * 
         */

        $this->_helper->redirector->gotoRoute(
    array(
        'controller' => 'rondas',
        'action' => 'list'
    )
);
    }

or using redirect or forward.. none have worked, the view is still the /rondas/choosetags and not /rondas/list

what is my error... thanks in advance..

Upvotes: 0

Views: 195

Answers (1)

Amit Malakar
Amit Malakar

Reputation: 608

Your initial view is /rondas/chooseronda when user press submit you make ajax call to /rondas/saveronda and send some data to it. Now if this is successful you want to redirect from the initial page (/rondas/chooseronda) to /rondas/list.

If the redirect code written in action /rondas/saveronda is not working, then you could return a success message back to initial view (/rondas/chooseronda), there you'll need to detect the success message in jQuery ajax code. If successful, put the redirect jQuery code, that will redirect it to /rondas/list.

Upvotes: 1

Related Questions