Javascript Ajax表单未提交表单rails
我在我的网站上使用了一个超级基本的谷歌表单。我正在使用此网站提取HTML以在我的网站上显示它- 一旦我点击提交,什么都不会发生。页面刚刚被锁定。我正在尝试重新提交到另一个页面。这是我的密码Javascript Ajax表单未提交表单rails,javascript,ruby-on-rails,ajax,Javascript,Ruby On Rails,Ajax,我在我的网站上使用了一个超级基本的谷歌表单。我正在使用此网站提取HTML以在我的网站上显示它- 一旦我点击提交,什么都不会发生。页面刚刚被锁定。我正在尝试重新提交到另一个页面。这是我的密码 <div class="row"> <form action="https://docs.google.com/forms/d/e/1FAIpQLSfJQ9EkDN8aggSL9AEB2PK4BGiZgBzLDbS1IPppfSkU1zy-oA/formResponse"target
<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>
$(“#bootstrapForm”).submit(函数(事件){
event.preventDefault()
var extraData={}
$(“#bootstrapForm”).ajaxSubmit({
数据:外部数据,
dataType:'jsonp',//这不会真正起作用。只是使用GET而不是POST来允许来自不同域的Cookie。
错误:函数(){
//表单提交应该成功,但是JSONP回调将失败,因为Google表单
//不支持它,因此这被视为失败处理。
警报('表单已提交。谢谢')
//您还可以将用户重定向到自定义感谢页面:
window.location=http://reif.com.au/thankyou'
}
})
})
在这件事上觉得有点傻。基本上,我没有复制所有的脚本。我正在赶过去。。总是第一个错误
<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>
这是我需要添加的,它现在成功提交和重定向 浏览器开发工具控制台有什么消息吗?没有,没有。我不确定,这是从提取网站上得到的。是的,需要jsonp。你应该添加一个
成功
回调:)