12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <!DOCTYPE html>
- <html lang="en">
- <head runat="server">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title></title>
- <script src="dist/jquery-1.7.1.js"></script>
- <script src="dist/ajaxfileupload.js"></script>
- </head>
- <body>
- <p><input type="file" id="file1" name="file" /></p>
- <input type="button" value="上传" />
- <p><img id="img1" alt="上传成功" src="" /></p>
- <script>
- $(function () {
- //$.support.cors = true;
- $(":button").click(function () {
- ajaxFileUpload();
- })
- })
- function ajaxFileUpload() {
- $.ajaxFileUpload
- (
- {
- url: 'http://192.168.2.236:5050/api/icss/lisExcelRes/lisExcelAnalysis', //用于文件上传的服务器端请求地址
- fileElementId: 'file1', //文件上传空间的id属性 <input type="file" id="file" name="file" />
- dataType: 'json', //返回值类型 一般设置为json
- success: function (data, status) //服务器成功响应处理函数
- {
- $("#img1").attr("src", data.imgurl);
- if (typeof (data.error) != 'undefined') {
- if (data.error != '') {
- alert(data.error);
- } else {
- alert(data.msg);
- }
- }
- },
- error: function (data, status, e)//服务器响应失败处理函数
- {
- alert(e);
- }
- }
- )
- return false;
- }
- </script>
- </body>
- </html>
|