I need to send form data to an API upon submission of the form. The API accepts the data in the URL itself. For example, a URL should look something like this...
The phone number and name etc are generated from the form.
If I copy the API URL into the browser with form data I get a simple "SUCCESS: Lead has been added" response, so I know it's working.
I'm fairly new to JS so I don't really know how to go about doing this. I've tried using a $.get() request, but it gives me a "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin null is therefore not allowed access" error. I understand that this is a cross origin request, so I tried a jsonp request but this gives me an "uncaught syntax error: unexpected identifier" error. This only occurs if the datatype is changed to jsonp, so I assume it has some issue with the ?callback=?... that's added for jsonp.
The only other solution I have come up with is to open the URL in a new window on submission of the form, and then immediately close it again with JS, but this is not an ideal solution.
Can anyone help?
Thanks