Okay here’s my situation.
I have a php file that contains a simple form asking for name, number, etc.
Now when I click submit, I have the form action set to a URL for an API that process those variables.
The problem is that when I submit the form, it takes me to a page where the API website confirms the submission with some jibberish xml text.
What I wanna do is be able to let the user fill the form data, secretly submit that data to the API URL, and display a thank you page for the user. I don’t want the user to be aware of the confirmation page of the API, just a form submission, which takes him directly to a thank you page.
The API accepts requests in the following form
"MY-API-URL.com/json?api_key=KEY&api_secret=SECRET&login=LOGIN&password=PASSWORD"
This is the form header..
<form action="MY-API-URL.com" class="login">
Any help is appreciated!
Make an ajax call to submit your form.
Make a self submitting form
action=""like this:Handle your form’s submit event with jQuery:
Update:
As far as I understand nexmo doesn’t support jsonp and you can’t use json because you are making cross-domain call.
There are plenty of posts about it here. For example json Uncaught SyntaxError: Unexpected token :
As a work around you can use proxy. You can read about it here and download simple proxy here.
If you would use a proxy mentioned above your code would look like:
I made it work on my machine, and it returned proper json response.