首页 > 解决方案 > 从同一个方法调用所有同类型的http请求

问题描述

在大型 Web 应用程序中,在通用 .js 文件中使用通用 javascript http_get方法(例如下面的示例)而不是分别编写它们是否有任何优点或缺点?

function http_get(url, async) {
    var post = $.ajax({
        type: "GET",
        url: url,
        async: async,
        dataType: "json",
        contentType: "application/json"
    });
    return post;
}

提前致谢。

标签: javascriptajax

解决方案


推荐阅读