Ajax return result correction and it's subsequent handling in js file
authorunknown <priyanka.karan26@gmail.com>
Wed, 17 Sep 2014 18:15:50 +0000 (19:15 +0100)
committerdeepak-srivastava <deepak.srivastava.0303@gmail.com>
Fri, 3 Oct 2014 09:08:26 +0000 (10:08 +0100)
CRM/Core/Page/AJAX/RecurringEntity.php
templates/CRM/Event/Form/ManageEvent/ConfirmRepeatMode.tpl

index a5e78c91cb9296fa5b7616288517881d84a4848b..575b6d82fdae4f2282b1955ee27b90bea2248d11 100644 (file)
@@ -35,10 +35,14 @@ class CRM_Core_Page_AJAX_RecurringEntity {
         $dao->entity_id = $entityId;
         $dao->entityTable = $entityTable;
       }
-      $dao->find(TRUE);
-      $dao->mode = $mode;
-      $dao->save();
-      $finalResult['status'] = 'Done';
+      
+      if($dao->find(TRUE)){
+        $dao->mode = $mode;
+        $dao->save();
+        $finalResult['status'] = 'Done';
+      }else{
+        $finalResult['status'] = 'Error';
+      }
     }
     echo json_encode($finalResult);
     CRM_Utils_System::civiExit();
index 3149c13581a71243d056da7d256b12ebcfffdadc..daa6fac1d9c24fb6042fdec41fc55ab6197e9e90 100644 (file)
           data: data,
           url:  ajaxurl,
           success: function (result) {
-            $("#repeat-mode-dailog").dialog('close');
+            if(result.status != "" && result.status == 'Done'){
+              $("#repeat-mode-dailog").dialog('close');
               $('#mainTabContainer div:visible Form').submit();
+            }else if(result.status != "" && result.status == 'Error'){
+              $("#repeat-mode-dailog").html('').append("<span id='error-text'>Some error ocurred, please try after some time</span>").css('color', 'red');
             }
+          }
         });
       }
     }