Answer the question
In order to leave comments, you need to log in
Why is the javascript redirect not working?
Good afternoon!
The feedback form is called using inline fancybox.
In an inline element
<form class="ask-form" id="ask-form" action='/send/index.php' method='POST' name='form' target='_blank'>
<div class="ask-title">задайте ваш вопрос</div>
<label for="name">представьтесь, пожалуйста</label>
<input id="name" required="" placeholder="" name="name" autocomplete="name"></input>
<label for="email">укажите email</label>
<input id="email" type="email" required="" placeholder="" name="email" autocomplete="email"></input>
<label for="tel">номер телефона</label>
<input id="tel" type="tel" required="" placeholder="" name="tel" autocomplete="tel"></input>
<label for="question">и ваш вопрос</label>
<textarea id="question" type="text" required="" placeholder="" name="question" autocomplete="question" rows="3"></textarea>
<input type="submit" value="отправить вопрос" class="btn btn-yellow btn-mediun btn-gcenter"></input>
</form>
document.getElementById('ask-form').onsubmit = function(){
var http = new XMLHttpRequest();
http.open("POST", "/send/index.php", true);
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
http.send("name=" + this.name.value + "&email=" + this.email.value + "&tel=" + this.tel.value + "&question=" + this.question.value);
http.onreadystatechange = function() {
if (http.readyState == 4 && http.status == 200) {
alert(http.responseText +', Ваше сообщение отправлено.\nСпасибо!');
setTimeout("document.location.href='/'", 1500);
}
}
http.onerror = function() {
alert('Извините, данные не были переданы');
}
return false;
}
setTimeout("document.location.href='/'", 1500);
Answer the question
In order to leave comments, you need to log in
var http = new XMLHttpRequest();
http.open("POST", "/send/index.php", true);
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
http.send("name=" + this.name.value + "&email=" + this.email.value + "&tel=" + this.tel.value + "&question=" + this.question.value);
http.onreadystatechange = function() {
if (http.readyState == 4 && http.status == 200) {
alert(http.responseText +', Ваше сообщение отправлено.\nСпасибо!');
setTimeout(function() { location.href='/'; }, 1500);
}
}
http.onerror = function() {
alert('Извините, данные не были переданы');
}
return false;
}
window.onload = function() {
document.getElementById('ask-form').onsubmit = function(){
var http = new XMLHttpRequest();
http.open("POST", "/send/index.php", true);
http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
http.send("name=" + this.name.value + "&email=" + this.email.value + "&tel=" + this.tel.value + "&question=" + this.question.value);
http.onreadystatechange = function() {
if (http.readyState == 4 && http.status == 200) {
alert(http.responseText +', Ваше сообщение отправлено.\nСпасибо!');
setTimeout(function() { location.href='/'; }, 1500);
}
}
http.onerror = function() {
alert('Извините, данные не были переданы');
}
return false;
}
};
what if it's like this?
setTimeout(function(){window.location.href='/'}, 1500);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question