Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9030153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:25:08+00:00 2026-06-16T07:25:08+00:00

Okay here’s my situation. I have a php file that contains a simple form

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T07:25:09+00:00Added an answer on June 16, 2026 at 7:25 am

    Make an ajax call to submit your form.

    Make a self submitting form action="" like this:

    <form id="login" name="login" action="" method="POST">
        <input type="text" name="login" value="">
        <input type="password" name="password" value="">
        <input type="submit" name="submit" value="Log in">
    </form>
    

    Handle your form’s submit event with jQuery:

    <script>
    $(function(){
        $("form#login").submit(function(){
            var login = $("input[name=login]").val();
            var password = $("input[name=password]").val();
    
            $.ajax({
                url: "MY-API-URL.com/json", 
                type: "POST",
                data: {"api_key":"KEY", "api_secret":"SECRET", "login":login, "password":password},
                dataType: "jsonp",
                cache: false,
                success: function (data) {              
                    //make your redirect here or just display a message on the same page
                    window.location = "congrats.html";
                },
                error: function(jqXHR, textStatus, errorThrown){
                    // handle your error here
                    alert("It's a failure!");
                }       
            });
            //cancel the submit default behavior
            return false;
        });
    });
    </script>
    

    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:

    <script> 
    $(function(){ 
        $("form#sms").submit(function(){ 
            var from = $("input[name=from]").val(); 
            var to = $("input[name=to]").val(); 
            var text = $("input[name=text]").val(); 
    
            var url = "http://rest.nexmo.com/sms/json?api_key=key&api_secret=secret" + "&from=" + from + "&to=" + to + "&text=" + text; 
            $.ajax({ 
                url: "simple-proxy.php", 
                type: "GET", 
                data: {"url": url}, 
                dataType: "json", 
                cache: false, 
                success: function (data) {               
                    //make your redirect here or just display a message on the same page 
                    console.log(data); 
                    if (data && data.contents && data.contents.messages && data.contents.messages.length) {
                        alert("The status is: " + data.contents.messages[0].status);
                    }
                    alert("SMS sent!"); 
                }, 
                error: function(jqXHR, textStatus, errorThrown){ 
                    // handle your error here 
                    alert("textStatus: " + textStatus + "\n" + "errorThrown: " + errorThrown); 
                }       
            }); 
            //cancel the submit default behavior 
            return false; 
        }); 
    }); 
    </script> 
    

    I made it work on my machine, and it returned proper json response.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay so here's the scenario: User is presented with form that contains file inputs.
Okay so here's, the scenario I have a thumbnail that contains an artists profile
Okay here's the situation. Net 4 WPF NO Silverlight. I have several Views that
Okay here's my situation. I have the following branches development development-kirby (270 commits ahead
Okay here is what I'm trying to do: I have a model object that
Okay so here is my database: I have a page on my .net form
Okay so here's the situation. I have this page of data. After the data
Okay here's my issue. I have a block that is 348px wide, and on
Okay so here my issue, I have a list of items that when a
Okay here is the problem, I have images of different sizes, but that doesn't

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.