I’m using PHP, and am wondering what the best way is to handle simple POSTs and AJAX POSTs without repeating code in the simplest way possible. Thanks!
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Just create a form like this:
And look what kind of request was fired in
formhandler.php:The only thing you need to know is that
$_SERVER['HTTP_X_REQUESTED_WITH']contains information if the form was submitted by an Ajax request