2016-09-15 3 views
-2
var xhttp = new XMLHttpRequest(); 
    xhttp.onreadystatechange = function() { 
     if (this.readyState == 4 && this.status == 200) { 
     console.log("excel download"); 
     } 
    }; 
    xhttp.open("POST", "exportGraphExcel", true); 
    xhttp.setRequestHeader("Content-type", "application/msexcel"); 
    xhttp.send('graphName=graphakki'); 

ブラウザで400のステータスを示します。 Content-typeが "application/x-www-form-urlencoded"に変更された場合、要求は受け入れられます。必須の文字列パラメータ 'graphName'が存在しません

+0

本当に質問ですか?それは何ですか? –

答えて

1

リクエストヘッダーのcontent typeは、の内容で、です。 Excelファイルを送信していない、Excelファイルを要求しています。

"application/x-www-form-urlencoded"コンテンツタイプヘッダーを送信すると、パラメータをURL(this is the standard way)で読み取る必要があることがサーバーに伝えられます。

関連する問題