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?
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);
?>
inscrever_curso.php
in your web browser? – Rob Aug 9 '09 at 21:55