I’m working on a bookmarklet that grabs info from a webpage and sends it to a Google Sheets spreadsheet using a form I made. Here’s the main part of my code:
The problem is nothing’s getting saved to the form when I use the bookmarklet. Is there a way to see what Google sends back in my code? I added jQuery to the bookmarklet if that helps.
I also tried looking at the Network tab in dev tools but it’s not picking up any activity from the bookmarklet. Maybe I should try using the ‘viewform’ method instead of ‘formresponse’?
Any tips on how to fill out and submit the form using JavaScript in my bookmarklet would be great. Thanks!
I’ve dealt with similar issues when automating form submissions to Google Sheets. One thing that helped me was using AJAX instead of a standard form submission. Here’s a snippet that worked for me:
This approach lets you handle responses and errors more easily. Also, make sure your form’s sharing settings allow anyone to submit responses. If you’re still having trouble, try using the ‘viewform’ URL instead of ‘formResponse’ to debug - it should show you the form with your data pre-filled.
I’ve encountered similar challenges when working with Google Forms and bookmarklets. One method that proved reliable for me is using the Fetch API with async/await, as it offers improved error handling and the ability to inspect responses effectively. In my implementation, I construct a FormData object by appending your required entries and then post it using fetch with the ‘no-cors’ mode. This usually bypasses CORS-related issues while still triggering the form submission. Replace ‘your-form-id’ with the actual ID of your form and verify that external submissions are enabled in your Google Form settings.