我需要在某个事件中插入用户的最后一个插入ID ..... 我希望在另一页上得到它.... 喜欢在产品页面....用户自定义他的产品......如mug customization
我需要将插入的....自定义产品ID添加到购物车页面,这是由ajax ....所以如何在产品页面的购物车页面上获取最后一个插入ID .... / p>
$('#store').click(function () {
$.ajax({
type: "POST",
url: ajax_url_store,
data: {
action: 'store',
views: JSON.stringify(thsirtDesigner.getProduct())
},
success: function (data) {
if (parseInt(data) > 0) {
//successfully added
document.getElementById('succes-message').innerHTML = 'You Design has Been SuccessFully Saved';
} else {
}
},
error: function () {
//alert('some error has occured...');
},
start: function () {
//alert('ajax has been started...');
}
});
});
我的ci功能
public function saveData() {
if ($this - > input - > post('action') == 'store') {
$views = $this - > input - > post('views');
$id = $this - > product_model - > save($views);
if ($id != '') {
header('Content-Type: application/json');
echo json_encode($id);
}
}
}
答案 0 :(得分:0)
public function saveData()
{
if ($this->input->post('action') == 'store')
{
$views = $this->input->post('views');
$id = $this->product_model->save($views);
$data = array('userid'=>$id); //insert id to userid as session variable
$this->session->set_userdata($data); //set userid as a session variable
if ($id != '')
{
header('Content-Type: application/json');
echo json_encode($id);
}
}
}