0

I am working on an Android jQuery Mobile application using PhoneGap, which does not allow me to use PHP. So I want to load an external PHP page that I'm hosting somewhere else. Basically this is what I'm looking for:
The user fills out the form then clicks on Submit
The external PHP page is loaded, and then it goes back to the confirmation page in my app.

Is this possible? I have been trying to do this for days and still cannot get it to work. It will either just load the external PHP page, or just the confirmation page, or it will load the confirmation page before the PHP page which leaves the users looking at a blank page. Any help would be greatly appreciated!

This is what I currently have:

$("#inputform").submit(function() {
    alert("test");
    $.getJSON("http://www.somewhere.com/sendemail.php");
    $.mobile.changePage("confirmation.html");
    return false;
});
2
  • Your external php code adds the form data to a database or does it fetch content Commented Apr 17, 2013 at 17:23
  • It just adds data into a database. It does not fetch anything. Commented Apr 17, 2013 at 17:25

1 Answer 1

1

What if you change the page to confirmation.html in the success event of the ajax request?

$.ajax({
    url: 'http://www.somewhere.com/sendemail.php',
    success: function(data, textStatus, XMLHttpRequest)
    {
        //do some work
        $.mobile.changePage("confirmation.html");
    }
});

OR with getJson

$.getJSON('http://www.somewhere.com/sendemail.php', function(data) {
    //do some work
    $.mobile.changePage("confirmation.html");
}

Here after a successful request to sendemail.php you will be able to do anything with the returned data and then direct to the confirmation.html page.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.