最近在上班时间看了一堆JQuery的插件,突然想把看到喜欢的插件一个个试着写个Demo,于是试着写了个ajaxfileupload的例子
看了一遍官网提供的例子,很快就写了出来,下面是大概的代码:
ajaxfileupload.aspx:
1
<script type="text/javascript">
2
//ajaxfileupload.js
3
function doajaxFileUpload(){
4
$("#loading")
5
.ajaxStart(function(){
6
$(this).show();
7
})
8
.ajaxComplete(function(){
9
$(this).hide();
10
});
11
$.ajaxFileUpload({
12
url: "ajaxfileupload.aspx",
13
secureuri: false,
14
fileElementId: "fileupload",//Input file id
15
dataType: "json",
16
success: function(data,status){
17
if(typeof(data.error) != 'undefined')
18
{
19
if(data.error != '')
20
{
21
alert(data.error + "sss");
22
}else
23
{
24
alert(data.msg + "aaa");
25
}
26
}
27
},
28
error: function (data, status, e)
29
{
30
alert(e + "99s");
31
}
32
});
33
</script>
34

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34









<!--注意,由于用了模板页,所以只帖出用到的代码--->
后台代码:





























插件地址如下: