douhuan3448 2013-04-17 17:07
浏览 52
已采纳

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;
});
  • 写回答

1条回答 默认 最新

  • duanhuayong6687 2013-04-17 17:27
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?