I want to delete data from multiple checkbox selected I fetch data from ajax request through but I don't know next process.
This is ajax form
<script type="text/javascript">
$(document).ready(function () {
$("#MyButton").click(function ()
{
var id = $('#grid').yiiGridView('getSelectedRows');
alert(id);
$.ajax({
type: 'POST',
url:'index.php?r=usermaster/multipledelete',
data: {id: id},
success: function () {
$(this).closest('tr').remove();
}
});
});
});
</script>
What exactly I want to delete this multiple data I got id through the ajax form
public function actionMultipledelete($id)
{
if (\Yii::$app->request->post()) {
$keys = \Yii::$app->request->post('id'); // id is array
}
if (!empty($keys)) {
$this->findModel($keys)->delete();
}
}