所以我想通过使用ajax来执行更新功能。我有两个参数,我想将参数传递给我的CI控制器。但是我遇到了一个错误,我认为这是没有传递给控制器的参数。
这是我的ajax函数:
function suspend(tipe, id){
var postData = {
'tipe' : tipe,
'id' : id
};
$.ajax({
type: "POST",
url: "<?=site_url("amas/c_agency/suspend_agency/");?>",
data: postData,
success: function(data){
if(tipe == 0){
$("#suspend").attr("onclick","suspend(1,"+id+")");
}else{
$("#suspend").attr("onclick","suspend(0,"+id+")");
}
alertify.success("Agency berhasil disuspend!");
} ,
error: function() {
alertify.error("Gagal suspend agency!");
}
});
}
这是我的代码初始化控制器:
function suspend_agency(){
$session['hasil'] = $this->session->userdata('logged_in');
$login_id = $session['hasil']->login_id;
$tipe = $this->input->post('tipe');
$id = $this->input->post('id');
if($tipe == 0){
$id = array(
'id_agency' => $id
);
$data = array(
'is_suspend' => '1',
'suspend_by' => $login_id,
'suspend_at' => date("Y-m-d")
);
}else{
$id = array(
'id_agency' => $id
);
$data = array(
'is_suspend' => '0'
);
}
$result = $this->m_agency->suspend_agency($id, $data);
}
我试图将ajax数据更改为数据:"tipe="+tipe+"&id="+id
,但它也不起作用。
答案 0 :(得分:0)
尝试此操作以打印变量。 FILE* in_fp, * fopen();
int main() {
if ((in_fp = fopen("TextFile.txt", "r")) == NULL)
printf("ERROR - cannot open front.in \n");
else
{
getChar();
do {
lex();
} while (nextToken != EOF);
}
echo json_encode($result);