var formData = new FormData($(this)[0]); $.ajax({ //url: window.location.pathname, url:"sql/raca-insert", type: 'POST', data: formData, success: function (retorno) { //console.log(retorno); var obj_retorno = $.trim(retorno); if(obj_retorno === '1') { $("#divMeio").load("racas-meio.php"); $('#btnSend').html('Adicionar'); $('#btnSend').attr('disabled', false); $('#txtNome').val(''); $('#txtNome').focus(); } else if (obj_retorno === '2') { $('#btnSend').html('Adicionar'); $('#btnSend').attr('disabled', false); $('#lblMsg').html('Esse nome já está sendo usado!') $('#lblMsg').show(); setTimeout(function() { $("#lblMsg").fadeOut('fast'); }, 3000); } else { $('#btnSend').html('Adicionar'); $('#btnSend').attr('disabled', false); $('#lblMsg').html('Algo deu errado, procure o suporte.') $('#lblMsg').show(); setTimeout(function() { $("#lblMsg").fadeOut('fast'); }, 3000); } }, cache: false, contentType: false, processData: false }); return false; //POST com parametros $.ajax({ type: "POST", url: "sql/centro-produto-update", data: { idcentro: idcentro, status: status, codigo: codigo, nome: nome, }, success: function(retorno){ //console.log(retorno); var obj_retorno = $.trim(retorno); //alert(data); if(obj_retorno === '1') { $("#divProdutos").load("centro-de-custo-produtos?id=" + idcentro); $("#msgok").show(); setTimeout(function() { $("#msgok").fadeOut('fast'); }, 3000); } if(obj_retorno === '2') { $("#lblPerguntaModalErro").show(); $("#txtPerguntaModal").focus(); $('#lblPerguntaModalErro').show(); setTimeout(function() { $("#lblPerguntaModalErro").fadeOut('fast'); }, 3000); return false; } } });