0
$(document).on('click', '#submit', function() {
    $( ".product-form" ).submit();
});

Whenever I use a button outside of a form and use jQuery submit to submit the form instead, I end up getting an empty $_POST array and my $_REQUEST array gets filled instead? Is there a way to prevent this from happening and get the normal submit behavior?

<form class="product-form" action="<?=url("product/create", false, $query)?>">
...
</form>
aLex
  • 1
  • 11
  • 1
    you say $_POST is empty and $_REQUEST is filled. Have you checked the contents of $_GET? Perhaps the jquery submit is sending a GET request instead of a POST request? – victor Apr 27 '17 at 16:24
  • Your form defaults to GET when no method is set. – Jay Blanchard Apr 27 '17 at 16:25

1 Answers1

2

$_POST is filled when your form method is POST. $_GET is filled when your form method is $_GET. $_REQUEST is filled in either case. If you're seeing your data in $_REQUEST but not $_POST then it means you're using GET in your form:

<form method="get" ...>

Change this to:

<form method="post" ...>
Alex Howansky
  • 50,515
  • 8
  • 78
  • 98