Hello. I'm trying to send a form to a PHP using $.ajax in Jquery. I send the whole thing as JSON, but, when I try to get the response, i get the 'parsererror'. What am I doing wrong? Thanks in advance.
Jquery fragment:
$("form").submit(function(){
$.ajax({type: "POST",
url: "inscrever_curso.php",
data: {cpf : $("input#cpf").val(),nome : $("input#nome").val()},
dataType: "json",
success: function(data){
alert("sucesso: "+data.msg);
},
error: function(XMLHttpRequest, textStatus, errorThrown){
alert ("erro: "+textStatus);
}
});
return false;
});
PHP:
<?php
$return[msg]="Testing, testing.";
echo json_encode($return);
?>