Use hidden iframe to submit data

2019-02-25 07:04发布

I need to submit some information to my servlet. Once I submit this information, I'll receive a PDF from the servlet based on the data. I know I can construct the URL and pass parameters to it using HTTP GET. Suppose my form data is too large.So is it possible to do this using a hidden iFrame? I'll submit the parameters using the hidden iFrame and in my servlet, I write the PDF to the response stream. Will this work? If it works can someone please suggest me how to do this?

3条回答
聊天终结者
2楼-- · 2019-02-25 07:50

Hm, which way do you want to sent the data using your iframe? I think you're limited to either GET or POST there, too. Means, if your data is too large, the iframe won't help sending your data.

What server backend do you use? You might be able to configure the maximum size of request data (post / get).

Please have a look at this message for more information about this.

查看更多
甜甜的少女心
3楼-- · 2019-02-25 08:01

You'll need to set the target to the iframe you want to submit it to.

<form action='...' name='theform' target='theiframe'>
  . 
  .
  .
  <iframe name='theiframe' src='...'> 
  </iframe>
</form>

This forum post has some details : http://forums.powweb.com/showthread.php?t=77213

查看更多
▲ chillily
4楼-- · 2019-02-25 08:02

In my eyes, using the hidden Iframe method is very old school, almost like before the great days of Ajax methods.

You can use jquery Ajax call and serialize your full form passing all variables. Remember to check your request size in your config, in case it post reaches maximum size.

查看更多
登录 后发表回答