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 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥30 用arduino开发esp32控制ps2手柄一直报错
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 求chat4.0解答一道线性规划题,用lingo编程运行,第一问要求写出数学模型和lingo语言编程模型,第二问第三问解答就行,我的ddl要到了谁来求了
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题