2012-10-28 17 views
6

Używam jquery ajax fileupload. plik zostanie przesłany correctkly ale mam błąd jakBłąd jQuery Handler nie jest funkcją

TypeError: jQuery.handleError is not a function 
[Break On This Error] 

jQuery.handleError(s, xml, status, e); 

jQuery w wersji 1.7.2, a kod jest

jQuery.ajaxFileUpload 
     (
      { 
       url:'<?php echo $currenturl.'&fileupload=enable';?>', 
       secureuri:false, 
       fileElementId:'fileToUpload', 
       dataType: 'json', 
       data:{'image_desc':image_desc,'gallery_id':curr_time_stamp}, 
       success: function (data, status) 
       { 

        if(typeof(data.error) != 'undefined') 
        { 
         if(data.error != '') 
         { 
          alert(data.error); 
         }else 
         { 
          alert(data.msg); 
          showprofilepicture(); 
         } 
        } 
       } 

      } 
     ) 

showprofilepicture function() również nie excuted.

Odpowiedz

22

jQuery.handleError usunięto po wersji jQuery w 1,5 trzeba napisać funkcję niestandardowej obsługi błędów, aby rozwiązać ten jak

jQuery.extend({ 
    handleError: function(s, xhr, status, e) { 
     // If a local callback was specified, fire it 
     if (s.error) 
      s.error(xhr, status, e); 
     // If we have some XML response text (e.g. from an AJAX call) then log it in the console 
     else if(xhr.responseText) 
      console.log(xhr.responseText); 
    } 
}); 

Patrz od blog. Dzięki John Main za informacje

0
   if(typeof(data.error) != 'undefined') 
      { 
       if(data.error != '') 
       { 
        alert(data.error); 
       }else 
       { 
        alert(data.msg); 
        showprofilepicture(); 
       } 
      } 

powinny być

jQuery.ajaxFileUpload({ 
      url:'<?php echo $currenturl."&fileupload=enable";?>', 
      secureuri:false, 
      fileElementId:'fileToUpload', 
      dataType: 'json', 
      data:{'image_desc':image_desc,'gallery_id':curr_time_stamp}, 
      success: function (data, status) 
      { 

       if(typeof(data.error) != 'undefined') 
       { 
        if(data.error != '') 
        { 
         alert(data.error); 
        } 
       }else 
        { 
         alert(data.msg); 
         showprofilepicture(); 
        } 
      } 

     } 
    ) 
+0

zmieniłem to, ale to nie działa, ustawiłem alert przed if, ale alarm nie działa – jackyesind