ajax+php (jquery.form插件)实现异步文件上传

<!DOCTYPE html>
<html lang="CN">
<head>
	<title>upload model</title>
	<metahttp-equiv="Content-Type"content="text/html;charset=gb2312"/>
	<script type="text/javascript" src="js/jquery.min.js"></script>
	<script type="text/javascript" src="js/jquery.form.js"></script>
</head>
<body>
    <label>Filename:</label>
    <form id="form" action="upload_file.php" method="post" enctype="multipart/form-data">
		<input type="file" name="file" id="file" /> 
		<input type="button" value="Upload" name="button" id="button"></button>
    </form>

	<script type="text/javascript">
	    $(document).ready(function () {
	    	var options = {
	    		success: function (data) {
	    			$("#responseText").text(data)  //responseTest没实际意义
	    		}
	    	};
	    	$("#button").click(function () {
	    		$("#form").ajaxSubmit(options);
	    	});
	    });
	</script>
</body>
</html>

 注意,Jquery最低版本为v1.5

参考:http://www.cnblogs.com/heyuquan/p/form-plug-async-submit.html

posted @ 2016-01-08 14:37  记忆书签  阅读(264)  评论(0编辑  收藏  举报