2014-02-12 33 views
1

我有一個jtable有一個listAction,它調用控制器中的一個動作來返回表中的數據。如果用戶刷新頁面,而動作正在進行的警報:錯誤處理來自jQuery的ajax調用jtable

enter image description here

這裏是JTable的:

$('#cuserTable').jtable({ 
     title: 'Users', 
     paging: true, 
     pageSize: 15, 
     sorting: true, 
     ajaxSettings: { 
      contentType: 'application/json' 
     }, 

     actions: { 
      listAction: '@Url.Action("LoadUserTable")' 
     }, 
     . 
     . 

如何以及在哪裏可以添加錯誤處理程序來顯示自定義警報(或甚至不顯示警報),如果用戶在表加載/重新加載過程中刷新?

回答

0

可以辦理該對話框中的錯誤消息:

想象一下,你正在執行更新,並要返回到對話框消息時發生錯誤:Dialog error message

try{ 
    //UPDATING 
    [...] 
    Your update code goes here 
    [...] 
    $jTableResult = array(); 
    $jTableResult['Result'] = "OK"; 
    echo json_encoded($jTableResult); 
}catch(Exception $ex){ 
    $jTableResult = array(); 
    $jTableResult['Result'] = "NOK"; 
    $jTableResult['Message'] = "Error while updating the record XYZ"; 
    echo json_encoded($jTableResult); 
}