I encounter a strange occurrence with posting information through Ajax. The script is nothing complex
$.post('somefile.php?arg1=somearg&ar2=somearg', {
somearg: variable,
...
}, function(response){});
The weird part is when clicking the save button for 1st and 2nd time, the server throws and error that $_POST
is empty. But when clicking for 3rd and 4th time, it works, without modifying anything on the page.
I know about the php config post_max_size or upload_max_size, it's not a problem and the data is very few.
Please help.
Maybe just try:
jQuery('#loader').show();
jQuery.ajax({
type: "POST",
url: yourURL,
data: {somearg: variable, id: variable2}
}).done(function( data ) {
console.log(data);
jQuery('#loader').hide();
});
You're actually sending your data with get method using $.post
$.post('somefile.php?arg1=somearg&ar2=somearg', {
// These are request parameters ^ ^
// and you'll find them in $_GET
}, function(response){});
In order to post them pass them as the second argument of $.post
eg
$.post('somefile.php','arg1=somearg&ar2=somearg',function(response){});
or
$.post('somefile.php',{arg1:'somearg',ar2:'somearg'},function(response){});