

').html(data.redirect_url).text();
return;
}
var successText = data.success_text;
$(blockId + '_progress_text').update('สำเร็จ');
Effect.Fade(blockId + '_form', {
duration: 0.5, from: 1, to: 0,
afterFinish: function () {
$(blockId + '_success_text').update(successText).show();
Effect.Fade(blockId + '_success_text', {
duration: 0.5, from: 0, to: 1
});
if (0)
Effect.ScrollTo(blockId + '_success_text', {
duration: '0.1',
offset: -window.innerHeight / 2
});
}
});
} else {
$(blockId + '_submit_button').enable();
if ($(blockId + '_sending_data'))
$(blockId + '_sending_data').hide();
if ($(blockId + '_submit_button'))
$(blockId + '_submit_button').enable();
var errorTxt = '';
if (data.errors && typeof (data.errors) == "string") {
errorTxt = data.errors.unescapeHTML();
} else {
errorTxt = 'Unknown error(s) occured';
}
swal.fire({
title: 'ข้อผิดพลาด',
html: errorTxt,
type: 'error'
});
if (data.script) {
eval(data.script);
}
}
},
error: function (xhr, status, errorThrown) {
console.log('Error happens. Try again.');
console.log(errorThrown);
}
});
});
});
});