mercredi 4 février 2015

Ajax POST with jQuery throwing empty errors


i'm trying to fix the following, simple code:



$(document).ready(function()
{
$("#login").click(function()
{
var a = 3;
var b = 2;
var dataString = "a="+a+"&b="+b;
console.log(dataString);
$.ajax({
url: "ajax.php",
type: "post",
data: dataString,
cache:"false",
beforeSend: function(){console.log("Sending...");},
error: function(x,y,z){console.log("err: "+x+" "+y+" "+z);},
success: function(x,y,z){console.log("succ: "+x+" "+y+" "+z);}
});
});
});


ajax.php:



<?php
$a = $_POST['a'];
$b = $_POST['b'];

echo $a+$b;
?>


My problem is that, the site always returns with error and emtpy x,y,z.





Aucun commentaire:

Enregistrer un commentaire