kennedy32
V2EX  ›  PHP

如何同一个 form 同时发起两个 post

  •  
  •   kennedy32 · Jul 27, 2014 · 6557 views
    This topic created in 4485 days ago, the information mentioned may be changed or developed.
    想要实现客户填写一次form,submit之后post方式同时提交到两个页面,不知道大家有什么好的解决方案。
    9 replies  •  2014-07-28 14:08:05 +08:00
    andy12530
    andy12530
    Jul 27, 2014
    1
    AJAX post 你想提交到多少页面就多少页面。
    jaytags
    jaytags
    Jul 27, 2014
    2
    1.页面隐藏2个form表单,可以设置一个的属性是target="_blank"
    2.你的提交按钮只是一个单独的button并绑定一个事件。
    3.绑定事件先提交(form1.submit())_blank的form,再去提交另外那个。
    fasling
    fasling
    Jul 27, 2014
    3
    不知道你的具体场景是啥,在我看来,应该用一个接口来封装,而不是让客户端多承担一次逻辑。
    incompatible
    incompatible
    Jul 27, 2014
    4
    这个应该在服务端做吧 这样也利于控制事务
    kennedy32
    kennedy32
    OP
    Jul 27, 2014
    5
    @andy12530 怎么做?
    izoabr
    izoabr
    Jul 28, 2014
    6
    我觉得也是,应该是两个form的数据都提交到一个服务器上,或者第三服务器上,然后由第三服务器去做数据分发,否则这样一次提交两个form,有一个form有问题,那整个提交操作都不好了,而且你有时会不知道不好在哪里...
    最后可能形成数据混乱
    bombless
    bombless
    Jul 28, 2014
    7
    ajax吧,或者不嫌烦的话把其中一个form的内容全部编码到另一次post,让那次post返回的页面来提交,虽然这样有性能问题233
    tonghuashuai
    tonghuashuai
    Jul 28, 2014
    8
    ajax
    SoloCompany
    SoloCompany
    Jul 28, 2014 via Android
    9
    自己写段简单的代码把form克隆成只有hidden input的新form,然后提交克隆的form
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1735 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 12:29 · PVG 20:29 · LAX 04:29 · JFK 07:29
    ♥ Do have faith in what you're doing.