避免"双重发布"浏览器消息与web到pdf api帖子

时间:2018-04-16 09:26:54

标签: javascript html post convertapi

我有一个使用转换API的v2的网络到pdf按钮。

<form action="https://v2.convertapi.com/web/to/pdf?Secret=XXX&download=attachment" method="post" enctype="multipart/form-data">
    <input type="hidden" name="Url" value="https://www.zg.ch/behoerden/baudirektion/statistikfachstelle/daten/gemeindeportraits.html" />
    <input type="hidden" name="FileName" value="Portrait" />
    <input type="hidden" name="ConversionDelay" value="5" />
    <input type="hidden" name="ViewportWidth" value="1200" />
    <input type="hidden" name="ViewportHeight" value="1887" />
    <input type="hidden" name="PageSize" value="a4" />
    <input type="submit" value="Portrait als PDF ausgeben"/>
</form>

根据页面上的选择,使用jquery更改URL。那部分也有效。

问题在于,人们通常需要提交两次甚至更多才能获得他们想要的所有PDF格式,并收到一条浏览器消息,警告他们他们将要再次提交该表单。有没有办法避免这个消息?

一种方法是为每个可能的文件创建一个按钮,并根据使用javascript / jquery的选择隐藏显示整个按钮,但这似乎效率低下。

由于我在CMS工作,我只能使用html和javascript。

感谢您的帮助。

2 个答案:

答案 0 :(得分:2)

我不确定,但是一旦遇到类似的问题。 我通过传递随机变量或时间戳以及URL来解决它 即,

https://v2.convertapi.com/web/to/pdf?Secret=XXX&download=attachment&ignorethisparam=currenttimestamp

答案 1 :(得分:0)

谢谢@ manu-avs,您的回复让我有了解决方案。在我的例子中,我使用jQuery将一个随机参数添加到action-url。

UITextField