I'm going to work with a HTML form using AJAX and a PHP file to manage data but neither success message or error message work. I tried firebug but it's like it waits something when occur the $.ajax statement then it "crashes".
<form id="alcoholic-form" name="alcoholic-form" method="post">
<fieldset>
<input type="submit" id="submit" value="Invia">
</fieldset>
</form><!-- form -->
<div id="risultato"></div>
<div id="errore"></div>
The controller.js file:
$(document).ready(function(){
$("#submit").click(function(){
//var formData = $("#alcoholic-form").serialize();
var nome = "nico";
var cognome = "basi";
$.ajax({
type: "POST",
url: "prova.php", //data manager
data: "nome=" + nome + "&cognome=" + cognome, //data to server
dataType: "html", //return value format
success:function(msg){
$("#risultato").html(msg);
alert(msg);
},//success
error: function(xhr, status, error) {
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
});//ajax
});//submit click
});//document ready
And then the prova.php file:
<?php /* questionario.php */ ?>
<?php
$nome = $_POST['nome'];
$cognome = $_POST['cognome'];
echo "nome = " . $nome . " cognome = " . $cognome;
?>
Thank you in advance