ajax local.href不跳转的原因之一

本文介绍了一个关于Ajax调用next.html时遇到的问题及解决方法。作者在使用Ajax尝试跳转到next.html页面时遇到了next.html is not a function的错误提示,通过检查发现是由于函数调用时遗漏了括号导致的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

ajax local.href不跳转的原因之一

打开F12发现一直报

next.html is not a function……

后来发现next少了(),看得我尴尬症都犯了

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="./CSS/index.css"> <script type="text/javascript" src="./js/jquery-3.3.1.js"></script> <title>Document</title> </head> <body> <div class="divclass"> <button onclick="getLogIn()">log in</button> <hr> <input type="file" id="uploadFile" name="uploadFile" /> <button onclick="addFile()" type="submit">提交</button> <hr> <input type="text" id="downloadfilename"> <button onclick="downloadFile()" target="new target">下载</button> </div> </body> <!-- http://127.0.0.1:8082/localTest/upload --> <!-- http://127.0.0.1:8082/localTest/testDownload --> <script> function getLogIn() { window.location.href = "./pages/login.html"; } function downloadFile() { var filename = document.getElementById("downloadfilename").value; //window.open("http://127.0.0.1:8082/localTest/testDownload?filename=" + encodeURI(filename)); window.open("http://127.0.0.1:8088/api/DownloadByCustomer?filename=" + encodeURI(filename)); } function addFile() { var formData = new FormData(); formData.append("file1", document.getElementById('uploadFile').files[0]); $.ajax({ url: 'http://127.0.0.1:8088/admApi/admUpload', type: 'POST', data: formData, // 上传formdata封装的数据包 //dataType: 'JSON', timeout: 10000, cache: false, // 缓存 processData: false, // jQuery要去处理发送的数据 contentType: false, // jQuery要去设置Content-Type请求头 success: function (res) { console.log(res) console.log("上传成功"); return alert("上传成功"); }, error: function (sd) { console.log(sd) console.log("上传失败"); return alert("上传失败"); } }); }; </script> </html>
06-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值