3 回答

TA貢獻1783條經驗 獲得超4個贊
使用此代碼:-
function saveAnswer(){
var inputAnswer = $('#userAnswer').val();
$.ajax({
type: "GET",
url: GLOBAL_URL + '/Session/saveAnswer?&inputAnswer='+inputAnswer,
dataType: 'json',
sucess:function(result){
alert(result);
},
});
}
結果將攜帶您的 id 并將顯示在警報框中,并且從 ajax 返回 id 使用此代碼:-
function saveAnswer(){
$data = array(
'id' => uuid(false),
'answer' => $this->input->get_post("inputAnswer")
);
$this->db->insert('tableAnswer', $data);
$id = $this->db->insert_id;
if($id > 0){
echo $id;
}
}
如果你得到了結果,別忘了勾選它,以便其他人可以得到幫助
- 3 回答
- 0 關注
- 124 瀏覽
添加回答
舉報