douding7189 2015-06-26 10:32
浏览 51
已采纳

Laravel和Bootstrap - 没有动作的表单仍在发送数据

I'm working on a Laravel site built by someone else and one of the pages has a form on it that doesn't have any action or any obvious location the data gets sent to, yet it still sends data to the back-end.

The form below is found on portal.blade.php - I can't find anything in there resembling Form::

If I delete the classes 'inspiring' & 'submit' from the submit button the form stops working.

Live page: http://amazingyou.bravissimo.com/about

<!-- Modal -->
<div class="inspiring modal fade" 
  id="myModal" 
  tabindex="-1" 
  role="dialog" 
  aria-labelledby="myModalLabel" 
  aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" 
         class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
        <h4 class="modal-title" id="myModalLabel">Your Amazing Story</h4>
      </div>
      <div class="modal-body">
        <form>
          <p>
            <input class="name" placeholder="Your Name" value="">
          </p>
          <p>
            <input class="title" placeholder="Story Title" value="">
          </p>
          <p>
            <textarea class="story" 
              placeholder="Your Story (max. 150 words)"></textarea>
          </p>
        </form>
        <div class="results" style="display:none">
          Thank you for your Amazing Story
        </div>
        <div class="character-limit" style="display:none">
          Please limit your story to 150 words
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" 
          class="btn btn-default" 
          data-dismiss="modal">Close</button>
        <button 
          onClick="ga('send', 'event', 'amazing_story', 'click', 'submit_story');" 
          type="button" 
          class="btn btn-primary inspiring submit">Submit</button>
      </div>
    </div>
  </div>
</div>
  • 写回答

2条回答 默认 最新

  • dsfds2353 2015-06-26 20:42
    关注

    It appears that your form is being submitted by JavaScript. Look through the JavaScript source files that are being included on this page. If you are using jQuery, look for something like

    $('.inspiring').bind('click', function(e){ ... });
    

    if regular JavaScript look for

    document.forms[0].onsubmit = function () { ... } );
    

    Inside there they are probably doing an ajax request, or they set the action and submit the form from there.

    Edited per comments

    The form is being submitted by this javascript file.

    http://amazingyou.bravissimo.com/js/user_inspiring_backbone.js

    Line 2 The URL for the form is set here.

    InspiringStories = Backbone.Model.extend({
        urlRoot: '/inspiring-stories',
        defaults: {
    
        },
        initialize: function(){
        }
    });
    

    Lines 17-19 Set up the click event.

    events: {
        "click .inspiring.submit": "clicked"
    },
    

    Line 21 starts the clicked function

    Line 78 submit the form when you hit model.save, everything between lines 21 & 78 is form validation.

    this.model.save([],{
        dataType:"text",
        success:function(response) {console.log(response)},
        error:function() {}
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥15 统计大规模图中的完全子图问题
  • ¥15 使用LM2596制作降压电路,一个能运行,一个不能
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错
  • ¥20 @microsoft/fetch-event-source 流式响应问题