jquery异步上传组件SmartUpload

 

源码:

 

  
  
  
  
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
  2. <html> 
  3. <head> 
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
  5. <title>SmartUpload</title> 
  6. <link rel="stylesheet" href="reset.css"></link> 
  7. <link rel="stylesheet" href="demo.css"></link> 
  8. <style> 
  9. @media screen and (-webkit-min-device-pixel-ratio:0){ .ks-smartupload-file {margin-left:-370px;} }  /*chrome and safari*/ 
  10. </style> 
  11. </head> 
  12. <body> 
  13. <h1>SmartUpload(Default)</h1> 
  14. <div>默认模式</div> 
  15. <div class="wrapper"><a href='#' id="J_btn" class='J_btn'>上传</a></div> 
  16. <script type="text/javascript" src="jquery-latest.min.js"></script> 
  17. <script type="text/javascript" src="smartupload.js"></script> 
  18. <script type="text/javascript"> 
  19. (function($){ 
  20. /** 
  21.  * $.fn.SmartUpload(target,cfg)  
  22.  * @param target 上传按钮  
  23.  * @param cfg 配置项 
  24.  * 
  25.  */ var title = ""
  26.      
  27.         var su = new $.fn.SmartUpload("#J_btn",{ 
  28.             //上传类型 
  29.             type:"iframe", 
  30.             //上传路径 
  31.             url:"upload.php", 
  32.             //返回类型 
  33.             //dataType:"json", 
  34.             fileName:"fileData", 
  35.             //回调 
  36.             success:function(data){ 
  37.                 //callback 
  38.                 alert(data); 
  39.                  
  40.             } 
  41.              
  42.         }); 
  43.  
  44.         $("#J_submit").click(function(){ 
  45.             //可以传输动态获取的数据至服务器 
  46.             su.setData({"sendData":$("#J_param_text").val()}); 
  47.              
  48.             su.submit(); 
  49.              
  50.         }); 
  51.          
  52. })(jQuery); 
  53. </script> 
  54. </body> 
  55. </html> 

你可能感兴趣的:(jquery异步上传,兼容IE6+)