Ajax提交表单数据类型问题

我在使用ajax提交html输入表单时遇到了一些问题,而且datatype似乎有问题。

的背景:

  1. app engineaws发送输入表单
  2. aws上创建一个pdf文件,将其保存在s3 ,然后将超链接发送回app engine
  3. app engine端,生成带有超链接的html页面
  4. 如果ajax调用成功,则重定向到在Step 3创建的页面

输入表格:

 

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值有关:

  1. dataType: "html"ajax成功触发,但我收到错误消息: 405 Method Not Allowed The method GET is not allowed for this resource.
  2. dataType: "json"ajax错误被触发
  3. dataType: "data"ajax错误触发

我检查了服务器端,看起来无论我选择什么数据类型,总是生成pdf。 此外,当从console.log(data)触发ajax error时,我可以看到具有正确超链接的网页。 谁能给我一些建议? 谢谢!