这是我的控制人
public function listCurenrTask()
{
$id = $this->uri->segment(3);
$this->load->model('User_model');
$data['project'] = $this->User_model->select($id);
$this->load->view('taskView',$data );
if ($this->input->post() && $this->input->is_ajax_request()) { $projectid= $this->input->post('$this->session->userdata("projectid")');
$taskstatus = $this->input->post('taskstatus');
$date = $this->input->post('date');
print_r($taskstatus);die();
$credentials = array('projectid'=> $projectid, 'taskstatus'=>$taskstatus, 'date'=>$date);
$this->load->model('User_model');
if(!$this->User_model->taskNotes($credentials)){
$data['result'] = "fail";
echo json_encode($data);
} else {
$data['result'] = "Success";
echo json_encode($data);
redirect('/dashboard');
}
} else {
// $this->load->view('taskview');
// }
}
}
**在POST方法中搜索了很多教程,并且在这里也看到了回答的问题,但是我的POST仍然不起作用...我想如果你们看到我不喜欢的东西,我应该在这里发布!* *
脚本
<script>
$(document).ready(function(){
$('#submit').click(function(event){
event.preventDefault();
taskstatus=$('#taskstatus').val();
date=$('#date').val();
$.ajax({
type: "POST",
url: "<?php echo base_url(); ?>taskView"
data : {taskstatus:taskstatus,date:date},
dataType: 'json',
success : function(response){if(response.result==="fail"){
$('.show-message').html("Sorry, failed to change your password");
}else{
$('.show-message').html("Successfully changes your password");
}
},
error: function() {
alert("Something went wrong");
}
});
});``
});
https://i.stack.imgur.com/gJHVQ.png
答案 0 :(得分:0)
您定义了JS变量吗?