get response after ajax request
I am a noob at ajax, but I think my problem is fairly simple. After I
submit my form, I would like to have the server echo back to me. Here is
my current code which is not working. I'm fairly certain that the problem
is with my ajax, because I know that my values are being placed in
dataString.
HTML
<form method="POST" onSubmit="new_user(this);" >
<input type="submit" value="signed" name="astatus" />
<input type="hidden" value="FaKEIdkEy" name="mark_attend" />
</form>
Javascript
function new_user(form){
var url = "attendance.php";
var dataString = "status="+form.astatus.value;
dataString = dataString+"&id="+form.mark_attend.value;
$.ajax({
type: "POST",
url: url,
data: dataString,
success: function(data) {
alert(data);
}
});
}
php (attendance.php)
if(!empty($_POST))
{
echo "response";
}
Any Ideas on how to fix?
No comments:
Post a Comment