为什么在捕获异常后通过ajax调用此方法会继续执行?
以下是一个例子:
try{
$this->save_order(); //for testing purposed, guaranteed to throw exception
$this->set_order_number();
$this->set_plan_id(); //WHY DOES THIS STILL EXECUTE?
}catch(Exception $e){
header('Internal Server Error', true, 500)
echo json_encode(array('msg'=>$e->getMessage());
exit();
}
save_order
方法:
public function save_order()
{
if(1==1){
throw new exception('caught exception');
}
}
Jquery如果有人想看看它:
$.ajax({
'url': '/admin/payment_plan/ajax_finish_order',
'type': 'POST',
'dataType': 'JSON',
'data':{'some_data': some_var},
'success':function(status){
//do stuff
},
'error':function(error){
//do stuff
}