Action called twice when using js with form

Hi all,

I have this very odd problem.

This is my view:


<?php echo CHtml::beginForm('https://www.sandbox.paypal.com/webapps/adaptivepayment/flow/pay','',array('target'=>'PPDGFrame')); ?>

<?php echo CHtml::hiddenField('expType','light');  ?>

<?php echo CHtml::hiddenField('paykey',$paykey);  ?>

<?php echo CHtml::submitButton('Submit',array('id'=>'submitBtn')); ?> 


<?php echo CHtml::endForm(); ?> 


<?php

//	Event for paypal buy now

	$cs = Yii::app()->getClientScript();  

	$cs->registerScript(

	  'paypal_buy',

	  'var dgFlow = new PAYPAL.apps.DGFlow({ trigger: "submitBtn" });

	' 

	  ,

	  CClientScript::POS_END

	);

The $paykey is generated when the action is called and stored in a table. I noticed that for every the page loads the action is called twice! So there are two rows of paykey on each page load.

Now, if you so much as change the trigger: "submitBtn" to something else, like trigger: "none" - this does not happen. I have no idea why yii calls the action twice, maybe it has to do with Ajax?

Can anyone think of something here?

Thanks!

Are you using ajax to submit the form?

Check firebug how many calls there are being made

Thanks,

I am not using Ajax to submit. The paypal JS is opening a new frame with clicking on the submit.

How do I check how many called are being made?

You could use SESSION vars to keep track of actions (simple but effective)

I would first check if the javascript is inlcuded correctly (only once)