1. 模版中代码:
<select name="status" id="status_id" onchange="select_change({$result.ID},this.value,'url值');"> <option value="0" selected="selected" >a</option> <option value="1">s</option> </select>
2. js中代码
function select_change(inquiry_id,status,url){ // $.ajax({ type:"POST",url:url,dataType:'',// data: 'inquiry_id='+inquiry_id+'&status='+status,timeout: 2000,error:function(){},success:function(data){ if(data){ $("#tip").show(); $("#tips").hide(); }else{ $("#info").show(); } } }); }
3. PHP中代码:
if (Input::is_ajax()) { // $inquiry_id = (isset($_POST['inquiry_id'])) ? $_POST['inquiry_id'] : ''; $status = (isset($_POST['status'])) ? $_POST['status'] : ''; // if(!empty($inquiry_id)){ $result = Model_Admin_Inquiry_Detail::update_status($inquiry_id,$status); $json=array(); $json[]=$result; if($result==1){ echo json_encode($json); } } exit; }原文链接:https://www.f2er.com/ajax/164430.html