2012-10-28 27 views
6

Tôi đang sử dụng jquery ajax fileupload. các tập tin được tải lên correctkly nhưng tôi đã nhận lỗi nhưLỗi xử lý jQuery không phải là hàm

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

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

sử dụng jQuery phiên bản 1.7.2 và mã là

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(); 
         } 
        } 
       } 

      } 
     ) 

chức năng showprofilepicture() cũng không excuted.

Trả lời

22

Các jQuery.handleError đã được gỡ bỏ sau khi phiên bản jQuery trong 1,5 bạn cần phải viết một hàm xử lý lỗi tùy chỉnh để giải quyết như

này
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); 
    } 
}); 

Tham khảo từ số blog. Cảm ơn John Main về thông tin của bạn

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

nên

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

tôi đã thay đổi cài đặt này nhưng không hoạt động, tôi đặt cảnh báo trước khi nếu cảnh báo không hoạt động – jackyesind

Các vấn đề liên quan