Ajax表单没有提交表单rails

时间:2018-02-23 09:05:06

标签: javascript ruby-on-rails ajax

我在我的网站上使用超级基本的Google表单。我正在使用此网站提取HTML以在我的网站上显示它 - http://stefano.brilli.me/google-forms-html-exporter/

一旦我点击提交,没有任何反应。页面刚刚被锁定。我正在尝试将其重新提交到另一个页面。这是我的代码

<div class="row">
    <form action="https://docs.google.com/forms/d/e/1FAIpQLSfJQ9EkDN8aggSL9AEB2PK4BGiZgBzLDbS1IPppfSkU1zy-oA/formResponse"target="_self" id="bootstrapForm" method="POST">
        <div class="col-sm-6 col-md-3">
            <input id="679075295" type="text" name="entry.679075295" class="form-control" >  
        </div>
        <div class="col-sm-6 col-md-3">  
            <input id="897968244" type="text" name="entry.897968244" class="form-control" >
        </div>
        <div class="col-sm-6 col-md-3"> 
            <input id="685661947" type="text" name="entry.685661947" class="form-control" > 
        </div>
        <input id="503500083" type="hidden" name="entry.503500083" value="<%= @investment.id %>" >
        <div class="col-sm-6 col-md-3">  
            <button type="submit" value"submit" class="btn btn--primary type--uppercase" >Get Started</button> 
        </div>
    </form>    

这是ajax脚本

    <script>
        $('#bootstrapForm').submit(function (event) {
            event.preventDefault()
            var extraData = {}
            $('#bootstrapForm').ajaxSubmit({
                data: extraData,
                dataType: 'jsonp',  // This won't really work. It's just to use a GET instead of a POST to allow cookies from different domain.
                error: function () {
                    // Submit of form should be successful but JSONP callback will fail because Google Forms
                    // does not support it, so this is handled as a failure.
                    alert('Form Submitted. Thanks.')
                    // You can also redirect the user to a custom thank-you page:
                    window.location = 'http://reif.com.au/thankyou'
                }
            })
        }) 
    </script>
</div>

1 个答案:

答案 0 :(得分:0)

对这个感觉有点傻。基本上我没有复制所有的脚本。我正在冲过去......总是犯1号错误!

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.form/4.2.2/jquery.form.min.js" integrity="sha256-2Pjr1OlpZMY6qesJM68t2v39t+lMLvxwpa8QlRjJroA=" crossorigin="anonymous"></script>

这是我需要添加的内容,现在它已成功提交并重定向!