when I try to execute the code javascript function after writing all code I redirect the page to another page but it redirects to that page but my code which I write before window.location.href it is not executing please help me
code..
function Delete(){
var url_string = window.location.href;
var url = new URL(url_string);
var token = url.searchParams.get("token");
firebase.database().ref('Driver/'+token).remove();
console.log('it work')
window.location="../zozotidriver/display.php";
}
and if I remove window.location.href then my code execute but it not redirect.
I'm not an expert in firebase, but you probably have to handle the asynchronous part:
firebase.database().ref('Driver/'+token).on('child_removed', function (snapshot) {
window.location="../zozotidriver/display.php";
})
firebase.database().ref('Driver/'+token).remove();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.