ajax を使用して HTML 入力フォームを送信する際に問題が発生していdatatypeます。
背景:
- 入力フォームを から に送信
app engineするaws pdfでファイルを作成してawsで保存しs3、ハイパーリンクを に送り返すapp engine- 一方、
app engineハイパーリンクを含む html ページを生成する - ajax 呼び出しが成功した場合は、で作成されたページにリダイレクトします。
Step 3
入力フォーム:
<form id="pdf_post">
<table class="getpdf popup">
<!-- contents include 1. string type html table and jqplots -->
</table>
</form>
Ajax 呼び出し:
$(document).ajaxStart(function(){
alert('start');
});
$.ajax({
type: "post",
url: "/pdf.html",
data: $('#pdf_post').serialize(),
dataType: "html",
success: function () {
alert('success');
window.location = "/pdf.html";
},
error: function (data) {
console.log(data)
alert('error');
},
});
呼び出しに基づいてajax、ブラウザはハイパーリンクのあるページにリダイレクトされます。しかし、これは決して起こらず、結果は次の値に関連していますdataType。
dataType: "html"、ajax成功しましたが、エラーメッセージが表示されました:405 Method Not Allowed The method GET is not allowed for this resource.dataType: "json"、ajaxエラーが発生しましたdataType: "data"、ajaxエラーが発生しました
サーバー側を確認しましたが、選択した dataType に関係なく、常に pdf が生成されたようです。ajax errorが解雇されたときも、 からconsole.log(data)、正しいハイパーリンクを含む Web ページを見ることができます。誰か私にいくつかの提案をしてもらえますか? ありがとう!