2015-01-13 42 views
2

我似乎無法發送任何數據到服務器。即使我可以在我擁有的其他一些網頁中使用它,也很困難。唯一的區別是我正在使用這種特定形式的文件上傳。所有在鉻合金中運作良好。Firefox不發送POST數據到服務器

錯誤在哪裏?

<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> 

服務器沒有收到任何東西,但腳本本身正在被調用。

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

}else{ 
echo 'no input'; 
} 

也許錯誤與文件上傳無關。我試圖刪除文件上傳和enctype ='multipar/bal bla bal'。只是不起作用。沒有錯誤被記錄

+0

看看你的瀏覽器的開發者工具。給你的jQuery ajax調用添加一個'error'方法。看看JavaScript控制檯。它報告任何錯誤嗎?看看Net標籤。請求是否被提出?它會得到迴應嗎?它們是否包含您期望的數據? – Quentin

+0

使用FormData var data = new FormData(); – Azarus

+0

也許聽起來很有趣,但嘗試在URL(../call/insert-standart-add.call.php)之前添加2個點,希望它有幫助。 – mainronindeveloper

回答

1

問題是,FireFox不會發送提交輸入的值。在PHP的$ _POST中,它根本不存在。

至於修復,我沒有任何想法。

1

我討厭HTML有時...

無論如何。避免這個問題的最好方法是以一種明顯的跨瀏覽器方式不使用$ _POST ['submit']按鈕,因爲它不可靠。

因此,舉例來說,做到這一點:

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