1 回答

TA貢獻1811條經驗 獲得超4個贊
您必須在代碼中進行這樣的更改。希望它有效。
$('#click').click(function(){
var selected = new Array(); //assigning array to variable
$(".stafftable input[type=checkbox]:checked").each(function(){
selected.push(this.value);
});
var selected_member_id=localStorage.getItem('selectids');
var string_selected=selected.toString(); //converting array to string
$.ajax({
type: "POST",
url:"<?php echo base_url();?>Welcome/send_to_staff",
data: {staff_id:string_selected,members_id:selected_member_id}, //string selected
success:
function(data)
{
if(data==true){
// localStorage.clear();
load_unseen_notification();
}
else{
alert("localstorage not cleared");
}
}
});
});
在控制器中嘗試這樣,它可能會起作用。它對我有用
public function send_to_staff(){
$staff_id=$this->input->post('staff_id');
$staff_id=json_encode($staff_id); //converting to json
$membersids[]= $this->input->post('members_id');
$members_id=json_encode($membersids); //converting to json
if($staff_id !==''){
$data['staff_id']=$staff_id;
$data['members_id']=$members_id;
$inserted=$this->db->insert('ag_matched_members',$data); //insert query
if($inserted == true){
echo true; //returns true
}
else
{
echo false; //returns false
}
}
}
- 1 回答
- 0 關注
- 143 瀏覽
添加回答
舉報