我在使用 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>
阿贾克斯调用:
$(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
错误触发
我检查了服务器端,无论我选择什么数据类型,似乎总是生成一个 pdf。此外,当ajax error
被解雇时console.log(data)
,我可以从 中看到具有正确超链接的网页。谁能给我一些建议?谢谢!