jQuery ajax upload image
$(function(){
new AjaxUpload('file1', {
action: 'uploadpic.asp',
name: 'form1',
data:{act:'uploadfile',FormName:'form1'},
autoSubmit:false,
responseType:'json',
onSubmit:function(file,ext){
if (!(ext && /^(jpg|png|gif)$/i.test(ext))){
alert('ÇëÄúÉÏ´«jpg|png|gif¸ñʽµÄͼƬ!');
return false;
}
else{
$('#esave').show();
}
},
onComplete:function(file,response){
$('#esave').hide();
$('#pic').val(response.imgfile);
}
});
});
Ïà¹ØÎĵµ£º
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat=" ......
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode=Conditional>
<ContentTemplate>
<%=DateTime.Now %>
</ContentTemplate>
</asp:UpdatePanel> ......
ÏÖÔÚµÄÍøÒ³ÓÐÏ൱һ²¿·ÖÊDzÉÓÃÁËAJAX¼¼Êõ,²»¹ÜÊDzÉÓÃC#ÖеÄWebClient»¹ÊÇHttpRequest¶¼µÃ²»µ½ÕýÈ·µÄ½á¹û,ÒòΪÕâЩ½Å±¾ÊÇÔÚ·þÎñÆ÷·¢ËÍÍê±Ïºó²ÅÖ´ÐеÄ!
µ«ÎÒÃÇÓÃIEä¯ÀÀÒ³ÃæʱÊÇÕý³£µÄ,ËùÒÔ½â¾ö·½·¨Ö»ÓÐ1¸ö¾ÍÊDzÉÓÃWebBrowser¿Ø¼þ
µ«ÊÇʹÓÃWebbrowserÄã»á·¢ÏÖ,ÔÚDownloadCompleteʼþÖÐ,Äã¸ù±¾ÎÞ·¨ÖªµÀÒ³ÃæºÎʱ²ÅËãÊÇÕæÕýµ ......
Ò³ÃæÎļþÀàËÆ£º
<% using (Ajax.BeginForm("AjaxUpdate", 123, new AjaxOptions {
Confirm = "confirm str", LoadingElementId = "idLoading", UpdateTargetId
= "textEntered", OnSuccess = "validateForm" },new{id="idMyForm"}))
&nbs ......