$.ajax not function(已 解决:jQuery库冲突解决办法)
js文件开头已的定义$符号.导致后续,$.ajax 错误,不能识别$符号.,
参考:https://www.cnblogs.com/buwan/p/5346096.html
http://www.lovetime.top/2018/01/21/jQuery-clash-1/
得到灵感
文件开头自定的处:
const $ = (el) => document.querySelector(el);
$('.selectIpt').addEventListener('change', handleFiles);
function handleFiles() {
const files = this.files;
for (let i = 0, len = files.length; i < len; i++) {
showFilePreview(files[i]);
}
//上传文件
uploadfile();
}
修改前的:
<script>
var btn = document.getElementById("processTask");
btn.addEventListener('click',function(){
var method = GetUrlPara();
// console.log(method);
// console.log(filename);
$.ajax({
type: 'POST',
url: "/getfilename",
data: {"filename":filename,"method":method},
cache: false,
processData: false,
contentType: false,
success: function (ret) {
alert(ret);
}
});
},false)
</script>
修改后的:
//提交文件名称,执行操作方法
function commitfilename() {
jQuery.noConflict();
var method = GetUrlPara();
jQuery(document).ready(function(){
jQuery("#processTask").text("文件上传中....!")
jQuery.ajax({
type: 'POST',
url: "/ingetfilename",
data: {"filename":filename,"method":method},
dataType:"json",
success: function (ret) {
alert(ret);
}
});
})
}
赞赏码
非学,无以致疑;非问,无以广识