上面的代码会将我重定向到所需的页面,但不会将数据输入数据库。
如果我删除14:27:50: Executing external task 'build'...
:compileJava NO-SOURCE :processResources NO-SOURCE :classes UP-TO-DATE
:jar UP-TO-DATE :assemble UP-TO-DATE :compileTestJava NO-SOURCE
:processTestResources NO-SOURCE :testClasses UP-TO-DATE :test
NO-SOURCE :check UP-TO-DATE :build UP-TO-DATE :b-features:compileJava
UP-TO-DATE :b-features:processResources NO-SOURCE :b-features:classes
UP-TO-DATE :b-features:jar SKIPPED
/home/nikita/IdeaProjects/multi-project-reference/a-features/src/main/java/outerproject/A.java:3:
error: package innerproject does not exist import innerproject.B;
^ /home/nikita/IdeaProjects/multi-project-reference/a-features/src/main/java/outerproject/A.java:7:
error: cannot find symbol
B b = new B();
^ symbol: class B location: class A /home/nikita/IdeaProjects/multi-project-reference/a-features/src/main/java/outerproject/A.java:7:
error: cannot find symbol
B b = new B();
^ symbol: class B location: class A 3 errors :a-features:compileJava FAILED
FAILURE: Build failed with an exception.
命令,则数据已成功输入数据库。
我想一起完成这两项任务。出路是什么?
window.location.href
答案 0 :(得分:1)
您可以使用提及here的承诺来确定将用户重定向到Votingpage.html的安全时间
firebasep.set(newData).then(function(data){
alert("New");
window.location.href="Votingpage.html";
}).catch(function(error){
console.log(error);
});
答案 1 :(得分:0)
它会将您重定向到所需的页面,但不会将数据输入数据库,因为查询失败但您错误地将重定向代码放在错误回调中,修复了这样的代码,以便更清楚地看到发生了什么
firebase.set(newData)
.then((data) => {
// redirect here
})
.catch((error) => {
// display error here
});