Code:
<script>
$(document).ready(function () {
$("#submitbuy").click(function () {
alert("clicou no submitbuy");
var emailc = $("#emailc").val();
alert("variavel emailc atribuida: " + emailc);
$.ajax({
url: 'https://meusite.com/cadastro.php',
type: 'POST',
data: $("#forms").serialize(),
success: function () {
alert("entrou no success ajax");
if (data.length == 0) {
alert("forms foi submit");
$("#forms").submit();
} // if
else {
alert("forms não foi submit, alert data");
alert(data);
} // else
} // success
}); // ajax
}); // submitbuy.click
}); // document.ready
</script>
What happens: Displays the first two alerts, (I used them as debug) ps: in firebug does not point any error in this code above. But I did not display the third alert (which is inside the $ .ajax success).
What will be the problem? I have another ajax code on this same page, and it fulfills its role, I've scanned all possible errors, but nothing found ..
EDIT: Code form, to leave something more concrete: Form code is like this, it's very simple, just to capture the email:
<form action="https://www.meusite.com/paginax" method="POST" id="forms" name="forms">
<input name="emailc" id="emailc" placeholder="seu melhor email!" id="emailc" type="text">
</form>
The input is outside the form, type button, only to open the function for later submission in AJAX.