[Solved] My Ajaxrequest Is Posted Many Time

Hi dear Yiiers,

In my Page admin view, I can explore the Page model tree and open a form for editing a page while selecting an item in the tree.(I’m using simpleTree extension). This work nicely.

But when I update a page with an ajaxSubmit button, the POST request is executed many times, see logs on the screen capture



The view:

<div class="row">

	<div class="span3" id="pageTree">





	<div class="span9" id="pageEdit">



the pageTree partial:




		'modelPropertyParentId' => 'parent_id',

		'modelPropertyName' => 'title',

		'ajaxUrl' => $this->createUrl('/content/page/simpletree'),


		    var id = data.inst.get_selected().attr("id").replace("node_","");





Page Controller actions:

    //this is for displaying the form

	public function actionEdit($id)





    //for updating

	public function actionUpdate()












and in the form (_update.php):

			<?php $this->widget('bootstrap.widgets.TbButton', array(





				'ajaxOptions' => array ('update'=>'#pageTree')

			)); ?>

What’s wrong with this approach ?

Also, same js and css files are loaded many times …

Lets say that it’s the first load of my page admin view: jquery.js , jquery.jstree.js, redactor.min.js are loaded many times.

Why? I do not know.

Can this explain that once I submit the form, the POST action is repeated many times ?

OK, partially solved using this trick: That guy, Alain, has posted only once in the forums. But what a good one.

With that solution, my POST request is sended only once.