First off, thank you, this tool is a lot cleaner then what I used last time I tried to convert a form to be usable on a website!
I have been trying to get this to work (similarly to the demo, but, I am wanting this to post to console or show a toast notification). However, taking things one piece at a time, I am just trying to get the entire page to not auto-redirect when submit
is sent to the site so I don't get redirected to the postResponse page.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<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>
<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://www.mydomain.com/thankyoupage.html'
}
})
})
</script>
</head>
<body>
<form action="https://docs.google.com/forms/d/e/1FAIpQLSdls8ZHN0eT2UIKdC2FM730McPOxVPbY3WVJzsxtMQr5vKD1A/formResponse" target="_self" id="bootstrapForm" method="POST">
<legend for="744487962">Name</legend>
<div class="form-group">
<input id="672765353" type="text" name="entry.672765353" class="form-control" >
</div>
<legend for="1832426025">Email</legend>
<div class="form-group">
<input id="869555934" type="text" name="entry.869555934" class="form-control" >
</div>
<legend for="728820308">How did you find this website?</legend>
<div class="form-group">
<div class="radio">
<label>
<input type="radio" name="entry.401439447" value="Google" >
Google
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="entry.401439447" value="Github" >
Github
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="entry.401439447" value="__other_option__" >
</label>
<input type="text" name="entry.401439447.other_option_response" placeholder="custom value">
</div>
</div>
<input type="hidden" name="fvv" value="1">
<input type="hidden" name="fbzx" value="-4188684007662801280">
<!--
CAVEAT: In multipages (multisection) forms, *pageHistory* field tells to google what sections we've currently completed.
This usually starts as "0" for the first page, then "0,1" in the second page... up to "0,1,2..N" in n-th page.
Keep this in mind if you plan to change this code to recreate any sort of multipage-feature in your exported form.
We're setting this to the total number of pages in this form because we're sending all fields from all the section together.
-->
<input type="hidden" name="pageHistory" value="0">
<input class="btn btn-primary" type="submit" value="Submit">
</form>
</body>
</html>
I am a little confused as to how this is now operating, you are telling it to use jsonp
to use GET
instead of POST
, but, in the action, you state to use POST
.
If I could get a little assistance with this, that would be awesome.