我正在使用从 gridview 中选择的键传递(通过 post)一个数组,但我总是得到相同的 URL 错误:
POST http://localhost/cngrx/web/index.php/ponenciaresumen/[object%20Object] 404 (Not Found)
似乎代码生成总是这种模式: path/myController/[object%20Object] 我设置的 url 无关紧要,代码生成总是相同的 url,这不是我需要的。我的代码是这样的:
<script>
$(document).ready(function(){
$('#MyButton').click(function(){
var keys = $('#w1').yiiGridView('getSelectedRows');
$.post({
url: 'myController/myAction',
dataType: 'json',
data: {keylist: keys}
});
});
});
</script>
我已经尝试过绝对网址和亲戚之一,但没有。怎么会这样??
这是我在 myController 中的操作:
public function actionMyAction( ) {
if (isset($_POST['keylist'])) {
$keys = \yii\helpers\Json::decode($_POST['keylist']);
// you will have the array of pk ids to process in $keys
// perform batch action on these keys and return status
// back to ajax call above
}
}
感谢提前!