On Calling Delete Action

when i fire action delete


i got

Error 400

Invalid request. Please do not repeat this request again.

:angry: :angry:

Hi, in the code that gii generates for CRUD, the actionDelete starts with a check

if (Yii::app()->request->isPostRequest) {

So the delete action only works with a post (e.g. when called by submitting a form, not through a link). You can take out that validation out.

You can indeed take out that check, but you probably shouldn’t - it would leave your site open to XSS issues - any HTTP request which modifies something should be made using POST, and not GET.

Just create a POST form to trigger your delete action (or use ajax).

You should be glad. Because that’s the message hackers will receive when they’ve tried to wipe out your data via GET. ;)

Dear All

I still have this Error i made login and i need Delete row from grid view …

what can i do ??

i make the delete from grid view is POST and not from URL Link …

Can you post your urlManager configuration with all rules?


public function accessRules()


	return array(

		array('allow',  // allow all users to perform 'index' and 'view' actions




		array('allow', // allow authenticated user to perform 'create' and 'update' actions




		array('allow', // allow admin user to perform 'admin' and 'delete' actions




		array('deny',  // deny all users





Url Manager









I Hope if u can help me in it

Everything seems to be OK. Do you use Gii-generated code for delete action? Did you change anything in the code? Even the function parameter name?

yes i used Gii-gen and i didn t change anything …

and i dont use Ajax …and still cant delete …

do u have solution ???

Using CGridView you will only be able to delete if you are using Ajax - the link created for the delete button is a GET link to your delete action, and as such will fail when the delete action tests for POST request. If you use Ajax, then the request will be made using POST normally, and so should work - if it is not working, you’ll need to check the ajax request using Firebug to see what errors you are getting.

How I can Use Ajax with CGridview to delete ????????????

Ajax delete is a default option on CGridView - it should only not work if you have disabled it somehow.

If it is enabled and your requests are still not working, you will have to check what is happening in Firebug!

I saw in FireBug this Error


no element found

onload()22 (line 17)

for(i = 0; i < lis.length; i++) [/b]

I’m afraid you’ll have to be more explicit than that - we can’t do all debugging for you…

What script in what file does this error pertain to? Have you followed it upstream to see what could be causing it?

sorry sorry this error from other place but i still have error in delete is say

Error 400

Invalid request. Please do not repeat this request again.

First check in Firebug if all .js files loaded when opening page that contains gridview.

I had similiar problem when jquery.ba-bbq.js was loaded(or not loaded at all) before jquery.js.

Hi I had faced this problem. I had done this in way as below.


echo CHtml::ajaxLink('Delete',




				'data' => array('id' =>$rquiz->id,'type'=>'delete'),


				'success' => 'function(response) {





		array( 'confirm'=>'Are you sure to delete this question',)



I hope this could help you.


is important for you.

In ajax link above method type is post so in delete action

	public function actionDelete($id)





			// we only allow deletion via POST request






			// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser


				$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));



			throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');



I hope this will work.