2013-04-17 38 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的頁之後。