【问题标题】:jQuery Mobile load external PHP on form submitjQuery Mobile 在表单提交时加载外部 PHP
【发布时间】:2013-04-17 17:07:41
【问题描述】:

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

这可能吗?几天来我一直在尝试这样做,但仍然无法使其正常工作。它要么只加载外部 PHP 页面,要么只加载确认页面,或者它会在 PHP 页面之前加载确认页面,这会让用户看到一个空白页面。任何帮助将不胜感激!

这是我目前拥有的:

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

【问题讨论】:

  • 您的外部 php 代码将表单数据添加到数据库或获取内容
  • 它只是将数据添加到数据库中。它不获取任何东西。

标签: php forms jquery cordova jquery-mobile


【解决方案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 页面。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多