$(document).ready(() => {
$('#quote_form').on('submit', function () {
jQuery('#quote_form').addClass('form_sending');
$.ajax({
url: "/templates/easy_moving/sendmail.php",
method: "POST",
data: jQuery('#quote_form').serialize(),
contentType: false,
cache: false,
processData: false,
src: window.location.href,
success: function (data) {
console.log(data);
}
});
});
});
Ошибок нет, и не работает |
$('#quote_form').click(function(){
$.post(
'sendmail.php', // адрес обработчика
$("#quote_form").serialize(), // отправляемые данные
function(msg) { // получен ответ сервера
}
);
});
Тоже не пошло |
BorisJe,
чем это отличается от изначального варианта? |
$.ajax({
url: 'process.php',
type: 'POST',
data: 'passVarOne='+userName+'&passVarTwo='+emailAddress,
success:function(responseAnyNameHere) {
$('.responseArea').html(responseAnyNameHere);
},
statusCode:{
404:function(){
//$('.error').html("Page not found!");
alert( "file not found" );
}
}
}).done(function() {
alert( "success" );
}).fail(function() {
alert( "error" );
}).always(function() {
alert( "complete" );
});
Вот еще нашел код. Идея такая выполнить, прыгнуть в always и сделать редирект. Работает еще до fail |
BorisJe,
Это не поможет. При редиректе произойдёт отключение от серверного скрипта и тот завершится, не успев ничего отправить. Если не можете решить проблему на стороне сервера, то замените крутилку на прогресс-бар, рассчитанный на 15 секунд, плюс текст с извинениями и просьбой подождать это время. В идеале - ещё занять/развлечь чем-нибудь на это время: текстом, картинкой, и т.д. |
Цитата:
На 3.6 Делается по другому, но и быстрее работает. что сделал
$(document).ready(() => {
$('#quote_form').on('submit', function () {
jQuery('#quote_form').addClass('form_sending');
$.ajax({
url: "/templates/easy_moving/sendmail.php",
method: "POST",
data: jQuery('#quote_form').serialize(),
contentType: false,
cache: false,
processData: false,
src: window.location.href,
success: function (data) {
console.log(data);
}
});
});
});
На отправку не идет. почемуто |
Цитата:
$(document).ready(() => {
$(function() {
$('quote_form').submit(function(e) {
$.ajax({
url: '/templates/easy_moving/sendmail.php',
data: $("#quote_form").serialize(),
}).done(function() {
console.log('success');
}).fail(function() {
console.log('fail');
});
//отмена действия по умолчанию для кнопки submit
e.preventDefault();
});
});
});
Захожу во все кроме Done |
Цитата:
|
Цитата:
fail: error Internal Server Error |
$(document).ready(() => {
$(function() {
$('#quote_form').submit(function(e) {
$.ajax({
url: 'sendmail.php',
type: 'POST',
data: $("#quote_form").serialize(),
success:function(responseAnyNameHere) {
$('.responseArea').html(responseAnyNameHere);
},
statusCode:{
404:function(){
//$('.error').html("Page not found!");
alert( "file not found" );
}
}
}).done(function() {
alert( "success" )
}).fail(function(jqXHR, textStatus, errorThrown) {
console.log('fail: ', textStatus, errorThrown);
})
.always(function() {
alert( "complete" );
});
//отмена действия по умолчанию для кнопки submit
e.preventDefault();
});
});
});
Ошибок нет, везде успех но и не отправилось. Но отработало быстро |
| Часовой пояс GMT +3, время: 04:05. |