maxlight
(Nermin)
December 11, 2011, 2:44am
1
generated by gii:
array('label'=>'Delete', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete?'))
I changed to
array('label'=>'Delete', 'url'=>array('delete','id'=>$model->id)),
which gives this link:
index.php?r=cars/delete&id=2
which produces:
Invalid request. Please do not repeat this request again.
Why would that not work? Why does it work when using javascript popup?
edit:
I noticed delete is only allowed by post request, so the only option is to use javascript to do post and not get?
yiqing95
(Yiqing 95)
December 11, 2011, 7:39am
2
yes ! you are right;
in web developing , there is a basic knowledge:
GET is only for query , and is idempotent . means that you can do that any times and will get same effect;
POST is for command invoke . is used to affect server end , it is not idempotent. means if you do it multi_time you will get different result .
so update , insert and delete should use the POST instead of GET .
maxlight
(Nermin)
December 11, 2011, 11:52am
3
thanks for clarification you are ofcourse right, I’m getting back into web development after long break and I forgot some basic stuff
Reason I wanted to try get approach was that my javascript was malfunctioning because of some collisions with other javascript on the page, so pressing on Delete nothing happend. I still didn’t manage to solve that though