gpt4 book ai didi

php - 传递 javascript/ajax 参数时不会显示 codeigniter View

转载 作者:行者123 更新时间:2023-12-02 18:31:40 25 4
gpt4 key购买 nike

我正在将 codeigniter 与 phpgrid 集成,但在通过 javascript 和 codeigniter Controller 将行值从 phpgrid( View A 中)传递到另一个 View ( View B)时遇到问题

我在 PHPGRID 中有一个像这样的虚拟列( View A):

$col_formatter = <<<COLFORMATTER
function(cellvalue, options, rowObject, rowid){
var sessid = rowObject[0];

return '<input type="button" value="View" onclick="btnView('+sessid+')">';
}
COLFORMATTER;

以及 VIEW A 中的 javascript:

function btnView(sessid){
var dataRow = {
sessid:sessid,
};
$.ajax({
type:"POST",
url: "<?php echo base_url()."index.php/main/tes"; ?>",
data: dataRow,
success: function(msg){
}
});
return false;
}

在 Codeigniter Controller 中:

public function tes(){
$data['sessid'] = $_POST['sessid'];
$this->load->view('view_b', $data);
}

我似乎无法加载 View 。我使用 Mozilla 的 Firebug 来了解响应,确实响应是我的 view_b View 的代码,但是我如何切换到该 View ?

最佳答案

//Your are using ajax for some operation and want to reload the view page the you can test these options:
1) take a div in current view page and assing ajax retrun message to that div

function btnView(sessid){
var dataRow = {
sessid:sessid,
};
$.ajax({
type:"POST",
url: "<?php echo base_url()."index.php/main/tes"; ?>",
data: dataRow,
success: function(msg){
$("#divid").html(msg);
}
});
return false;
}


//Or 2)just redirect to your view page again

function btnView(sessid){
var dataRow = {
sessid:sessid,
};
$.ajax({
type:"POST",
url: "<?php echo base_url()."index.php/main/tes"; ?>",
data: dataRow,
success: function(msg){
window.location.href=path to your view page;//<?php echo base_url()."index.php/controller/function"; ?>
}
});
return false;
}

关于php - 传递 javascript/ajax 参数时不会显示 codeigniter View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17736588/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com