【问题标题】:What is the best method to use AJAX function on cordova apps?在科尔多瓦应用程序上使用 AJAX 功能的最佳方法是什么?
【发布时间】:2018-02-07 02:14:45
【问题描述】:

我对所有的 AJAX 函数都使用了 $.get 方法, 示例:

function getNotified() {
    spinner();
    $.get("http://www.easlyid.com/webservice.php", {
        ajx: "getNotified",
        email: localStorage.getItem("login_email")
    }, function (result) {
        alert(result);
        $("#mainContent").html(result);
        unspinner();
    });
}

$.get$.ajax 有什么区别?

在我的情况下,我应该使用哪一个? $.get 还是 $.ajax? 在cordova android应用程序上进行“AJAX调用”的最佳方法是什么?

【问题讨论】:

    标签: javascript android jquery ajax cordova


    【解决方案1】:

    本身没有“最佳”方法。重要的是使用的 http 方法是正确的。

    $.get 是 HTTP GET 请求的简写 jQuery 调用。对于 HTTP POST 请求,还有 $.post。如果您需要对后端调用进行更多自定义,例如使用自定义 HTTP 方法,请使用 $.ajax

    这是关于此的 jQuery 文档:

    https://api.jquery.com/jquery.get/

    https://api.jquery.com/jquery.post/

    http://api.jquery.com/jquery.ajax/

    GET 和 POST 的区别,参考这里:

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods

    GET 与 POST 的简单解释:

    https://www.w3schools.com/tags/ref_httpmethods.asp

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2016-05-29
      • 2017-06-08
      • 1970-01-01
      • 2017-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-05
      相关资源
      最近更新 更多