jQuery Mobile在表单提交上加载外部PHP

jQuery Mobile在表单提交上加载外部PHP

问题描述:

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;
});

我正在使用PhoneGap开发一个Android jQuery Mobile应用程序,它不允许我使用PHP。 所以我想加载一个我在其他地方托管的外部PHP页面。 基本上这就是我要找的东西:
用户填写表单然后点击提交
加载外部PHP页面,然后它返回到我的应用程序中的确认页面。 p>

这可能吗? 我一直试图这样做几天仍然无法让它工作。 它只是加载外部PHP页面,或只是加载确认页面,或者它将在PHP页面之前加载确认页面,使用户看到空白页面。 任何帮助将不胜感激! p>

这是我目前所拥有的: p>

  $(“#inputform”)。submit(function)  (){
 alert(“test”); 
 $ .getJSON(“http://www.somewhere.com/sendemail.php”); 
 $ .mobile.changePage(“confirmation.html”);  
返回false; 
}); 
  code>  pre> 
  div>

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.