当前位置: 代码迷 >> Java Web开发 >> $.ajaxFileUpload一样的使用方法,一个报错,一个成功
  详细解决方案

$.ajaxFileUpload一样的使用方法,一个报错,一个成功

热度:92   发布时间:2016-04-13 22:10:18.0
$.ajaxFileUpload同样的使用方法,一个报错,一个成功
报错页面
<script type="text/javascript" src="../js/ajaxfileupload.js"></script>
  <script type="text/javascript">
  function ajaxFileUpload1(fileName) {
  $("#some").remove();
      if(!/.(gif|jpg|jpeg|png|GIF|JPG|png)$/.test(fileName)){
           clearFile();
         }else{
          $.ajaxFileUpload
          (
          {
           url: 'xxx', 
                     secureuri: false, 
                     fileElementId: 'file', 
                     dataType: 'json', 
                     success: function (data, status)  
                           {
                            if(data.indexOf(".")>-1){
                     $("#glogo").css("display","none");
                     $("#glogo").attr("src","<%=basePath%>tempFile/"+data);
                     var img=document.getElementById("glogo");
                        if(img.width>100 && img.height>100){
                            $("#glogo").css("display","inline");
                        }else{
                            clearFile();
                        }
                    }else{
                     alert(data);
                        clearFile();
                    }
                    
                    
                           },
                     error: function (data, status, e)//服务器响应失败处理函数
                     {
                         alert(e);
                     }
          }
          )
         
         }
  }
</script>

错误:$.ajaxFileUpload    Uncaught TypeError: undefined is not a function



成功页面
<script type="text/javascript" src="../js/ajaxfileupload.js"></script>
  <script type="text/javascript">
  function ajaxFileUpload1(fileName) {
  $("#content").remove();
      if(!/.(gif|jpg|jpeg|png|GIF|JPG|png)$/.test(fileName)){
           clearFile();
         }else{
          $.ajaxFileUpload
          (
          {
           url: 'xxx', 
                     secureuri: false, 
                     fileElementId: 'file', 
                     dataType: 'json',
                     success: function (data, status) 
                           {
                            if(data.indexOf(".")>-1){
                     $("#glogo").css("display","none");
                     $("#glogo").attr("src","<%=basePath%>tempFile/"+data);
                     var img=document.getElementById("glogo");
                        if(img.width>100 && img.height>100){
                            $("#glogo").css("display","inline");
                        }else{
                            clearFile();
                        }
                    }else{
                     alert(data);
                        clearFile();
                    }
                    
                    
                           },
                     error: function (data, status, e)//服务器响应失败处理函数
                     {
                         alert(e);
                     }
          }
          )
         
         }
  }
  </script>

我用$.post时有时也会有这样的情况这是为什么?
------解决思路----------------------
 undefined is not a function  

undefined  不是一个函数,调试看看你
------解决思路----------------------
我也是,报错:Uncaught TypeError: $.ajaxFileUpload is not a function

按照网上的方法,还是没解决
http://chen-h.iteye.com/blog/1769457 参考
  相关解决方案