Insert via POST AJAX
Gostaria de uma ajuda dos senhores, pois não estou conseguindo inserir os registros na minha base de dados. Segue abaixo o código!
$(document).ready(function () {
$("#sendnews").click(function (e) {
e.preventDefault(). if ($("#email").val() === '') {
// Se input vazio informa Error
$('#status').show(). $('#status').addClass("alert-danger"). $('#status').text("Encontramos um error!"). return false. } $("#email").hide(). //hide input$("#sendnews").hide(). //hide submit button
$(".panel-body").hide(). //hide panel
$("#LoadingImage").show(). //show loading image var dataform = 'email=' + $("#email").val(). $.ajax({
type: 'post',
url: "/home/save",
dataType: "text", // Data type, HTML, json etc.
data: dataform,
success: function () { //se foi inserido com sucesso, Exibe mensagem de sucesso
$("#email").val(''). //empty text field on successful
//$("#status").append(response). $('#status').show(). $('#status').addClass('alert-success'). $('#status').text("Cadastro realizado com sucesso!"). $("#LoadingImage").hide(). //hide loading image
},
// Se Error
error: function (xhr, ajaxOptions, thrownError) {
$("#status").show(). //show message
$("#LoadingImage").hide(). //hide loading image
alert(thrownError). $('#status').addClass("alert-danger"). $('#status').text("Encontramos um error!"). } }). }). }). Discussão (7)
Carregando comentários...