日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

$.AjaxFileUpload is not a function

發(fā)布時(shí)間:2023/12/10 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 $.AjaxFileUpload is not a function 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>

..is not a function錯(cuò)誤的可能情況:

1、JS引入的路徑不對(duì)。檢查方法是看瀏覽器控制臺(tái)是否將JS載入了進(jìn)來(lái)。

2、JS引入順序不對(duì)。JS要在你使用之前引入

3、Jquery沒(méi)有第一個(gè)引入。

4、函數(shù)所在script標(biāo)簽,存在錯(cuò)誤函數(shù)。

5、函數(shù)名寫錯(cuò)了。

然后我發(fā)現(xiàn)按照網(wǎng)上很多人的寫法,無(wú)論如何都會(huì)出這個(gè)錯(cuò)。 這種寫法類似:

function ajaxFileUpload(){$.ajaxFileUpload({url:'update.do?method=uploader', //需要鏈接到服務(wù)器地址secureuri:false,fileElementId:'houseMaps', //文件選擇框的id屬性dataType: 'xml', //服務(wù)器返回的格式,可以是jsonsuccess: function (data, status) //相當(dāng)于java中try語(yǔ)句塊的用法{ },error: function (data, status, e) //相當(dāng)于java中catch語(yǔ)句塊的用法{}});}

最后我按照官方DEMO的格式寫,就OK了

<form method="post" action="" enctype="multipart/form-data"><label>File Input: <input type="file" name="file" id="demo1" /></label></form> $(document).ready(function() {var interval;function applyAjaxFileUpload(element) {$(element).AjaxFileUpload({action: "MyJsp.jsp",onChange: function(filename) {// Create a span element to notify the user of an upload in progressvar $span = $("<span />").attr("class", $(this).attr("id")).text("Uploading").insertAfter($(this));$(this).remove();interval = window.setInterval(function() {var text = $span.text();if (text.length < 13) {$span.text(text + ".");} else {$span.text("Uploading");}}, 200);},onSubmit: function(filename) {// Return false here to cancel the upload/*var $fileInput = $("<input />").attr({type: "file",name: $(this).attr("name"),id: $(this).attr("id")});$("span." + $(this).attr("id")).replaceWith($fileInput);applyAjaxFileUpload($fileInput);return false;*/// Return key-value pair to be sent along with the filereturn true;},onComplete: function(filename, response) {window.clearInterval(interval);var $span = $("span." + $(this).attr("id")).text(filename + " "),$fileInput = $("<input />").attr({type: "file",name: $(this).attr("name"),id: $(this).attr("id")});if (typeof(response.error) === "string") {$span.replaceWith($fileInput);applyAjaxFileUpload($fileInput);alert(response.error);return;}$("<a />").attr("href", "#").text("x").bind("click", function(e) {$span.replaceWith($fileInput);applyAjaxFileUpload($fileInput);}).appendTo($span);}});}applyAjaxFileUpload("#demo1");});

轉(zhuǎn)載于:https://my.oschina.net/u/2437172/blog/653254

總結(jié)

以上是生活随笔為你收集整理的$.AjaxFileUpload is not a function的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。