简体   繁体   中英

Ajax form not submitting form rails

I'm using a super basic google form on my website. I'm using this website to extract the HTML to display it on my website - http://stefano.brilli.me/google-forms-html-exporter/

Once I hit submit, nothing happens. The page is just locked. I'm trying to resubmit it to another page. Here is my code

<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>    

Here is the ajax script

    <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>

Feeling a little silly on this one. Essentially i didn't copy over all of the scripts. I was rushing through.. ALWAYS number 1 error!

<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>

This is what i needed to add, it now successfully submits and redirects!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM