How to check if a form has been submitted when there is no submit button
So i am using ajax request to submit a form through a link. However, when I want to receive inputs in my php, I don't know how to do so. For instance, I normally do this
if($_SERVER["REQUEST_METHOD"]=="POST&&isset($_REQUEST["register"]))
{
//do stuf here
}
But now when the ajax has submitted the code, how can I check form submission. I don't even have the register (inp开发者_如何转开发ut type submit). Whenever, I do so the error message shows `No such index'' for form inputs that are inside there.
Note that you can always check if the current request is an AJAX:
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest')
{
// This is an AJAX request, proccess the data from $_POST, $_GET or $_REQUEST
}
Normally you can define the type of the AJAX
request (POST
or GET
). If it is set to POST
and has the appropriate parameter (register
) then your PHP code should work.
精彩评论