ajax上傳文件附帶參數問題之 $(...).dialog is not a function

1、先引用兩個包

jquery-1.8.0.min.js和ajaxfileupload.js

<script src="${ctx}/js/jquery-1.8.0.min.js" type="text/javascript"></script>
<script src="${ctx}/js/ajaxfileupload.js" type="text/javascript"></script>


2、再上傳文件(這裏是上傳excel)和附帶的參數(id),

html

<form id="AnchorImportForm" method="post" enctype="multipart/form-data" ">
	<input type="hidden" id="pipeImportId" name="pipeImportId" value="${pipeImportId}"> 
		<div id="file_up" height="100" width="100%" style="margin-top:50px">
			 <input id="upfile" type="file" name="upfile" accept="xlsx"/>
		</div>
		<p></p>
		<input type="button" value="導入" style="text-align:center;background-color:#d9ffff;border:none;" onClick="File.upLoadFile()">
</form>

js

 File.upLoadFile=function(){
	 var id= document.getElementById("pipeImportId").value;
	$.ajaxFileUpload({
		 url: '${ctx}/sys/file/upLoadTwo',
		 secureuri:false,
        	 fileElementId: 'upfile',//上傳文件的id
        	 dataType: 'json',
         	data: {
            	 "pipeId": id
        	 },
         	success:function(result){
        		try{
				if(result.success){
					$('#dialogDivImport').dialog('close');
				}
					$.messager.show({
						title:'提示',
						msg:result.msg
					});
			}catch(e){
				$.messager.alert("警告",result.msg);
			}
        	 }
	});
} 


然後就報錯了... $(...).dialog is not a function


報這個錯的原因之一就是引用衝突。我這裏的

<script src="${ctx}/js/jquery-1.8.0.min.js" type="text/javascript"></script>
是衝突的,可能是外部已經引用了,在這裏刪除就OK了...



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章