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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵