kennedy32
V2EX  ›  PHP

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

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