Search code examples
phpajaxfirefoxpostsend

Firefox not sending POST data to server


I can't seem to send ANY data to the server. Even tough I can in some of the other pages that I have. The only difference is that I am using a file upload in this perticular form. All works well in chrome.

Where is the error?

<script>
        $( document ).ready(function() {
            $("#addnewadform").submit(function(e){
                e.preventDefault();
                $.ajax({
                    cache:false,
                    url: "/call/insert-standart-add.call.php", //URL IS CORRECT
                    type: "post",             // this is OK too
                    data: {submitStandartPost:'im sending the submit button value'}, //this is a super-simplified version of what i want the server to recieve
                    contentType: 'multipart/form-data',//i have tried a ton of different values for this
                    processData: false, //think this should be false for file uploads
                    success: function(data){
                        console.log(data);
                        if(data!==''){
                            console.log(data);
                        }else{
                            console.log("nothing was sent");
                        }
                    }
                });

            });
        });
    </script>

The server does not recieve anything, but the script itself is being called.

if(isset($_POST['submitStandartPost'])){

}else{
 echo 'no input';
}

maybe the error has nothing to do with file upload. I have tried to remove the file upload and enctype='multipar/bal bla bal'. just does not work. No errors being logged


Solution

  • I hate HTML at times...

    Anyway. The best way of avoiding this issue is in a clear cross-browser way is not to use $_POST['submit'] button because it's just not reliable.

    so, for example, don't do this:

    if(isset($_POST['submit'])){
    //do my form logic here
    }