2013-04-17 34 views
0

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

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

这是我目前有:

$("#inputform").submit(function() { 
    alert("test"); 
    $.getJSON("http://www.somewhere.com/sendemail.php"); 
    $.mobile.changePage("confirmation.html"); 
    return false; 
}); 
+0

您的外部php代码将表单数据添加到数据库中,还是获取内容 –

+0

它只是将数据添加到数据库中。它不会获取任何东西。 –

回答

1

如果你更改页面在Ajax请求的成功事件confirmation.html的?

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

:或的getJSON

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

这里成功的请求sendemail.php你将能够返回的数据做任何事情,然后直接到confirmation.html的页之后。