d.mc2
d.mc2

Reputation: 1129

Ajax Forms Return Success

I'm trying to learn from the http://jquery.malsup.com/form/#getting-started example. When I click submit, the alert of "Thank you for your comment" should pop up, however, it is not working for me. I was wondering if there was something you had to specifically add in comment.php that is being called by the form? Mine is just:

<?php 
echo $_POST['comment']; 
echo $_POST['name']; 
?>

Should there be like a return success or something? How would you implement it? Thanks

Upvotes: 0

Views: 241

Answers (1)

bbg
bbg

Reputation: 3072

I just got it to work after I noticed that the page wasn't actually loading any scripts.

If you copied-and-pasted the example HTML, as I did, try changing the src of the javascript, so that the scripts load and don't return 404s. I.e. instead of jquery-1.3.2.js, insert the full http://jquery.malsup.com/jquery-1.3.2.js.

<script type="text/javascript" src="http://jquery.malsup.com/jquery-1.3.2.js"></script>
<script type="text/javascript" src="http://jquery.malsup.com/form/jquery.form.js"></script>

Assuming there's no error, the PHP engine automatically returns a 200 success code in the header:

HTTP/1.1 200 OK

Upvotes: 1

Related Questions