weixin_33690367 2015-09-04 10:01 采纳率: 0%
浏览 38

PHP Ajax $ _POST随机为空

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.

  • 写回答

2条回答 默认 最新

  • weixin_33694620 2015-09-04 10:07
    关注

    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();
        });
    
    评论

报告相同问题?