0

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

的背景:

  1. 将输入表单从 发送app engineaws
  2. 在 上创建 一个pdf文件aws, 保存 它s3, 并将 超 链接 发回 到 .app engine
  3. 另一方面app engine,生成带有超链接的 html 页面
  4. 如果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

  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。此外,当ajax error被解雇时console.log(data),我可以从 中看到具有正确超链接的网页。谁能给我一些建议?谢谢!

4

0 回答 0