jQuery 3 slim ajax基本示例 [英] jQuery 3 slim ajax basic example

查看:162
本文介绍了jQuery 3 slim ajax基本示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是jQuery 3的新手。以下是一个基本的小提琴,使用以前的版本jQuery,但不适用于jQuery 3

I'm new to jQuery 3. The following is a basic fiddle, working with previous versions of jQuery, but does not work with jQuery 3

$(function() {
    $.ajax({
        url: '/echo/json',
        type: 'GET',
        dataType: 'json',
        success: function(data) {
            console.log(data)
        }
    });
})

在控制台中,我收到此错误:

In the console, I get this error:


jquery-3.1.1.slim.min.js:2 jQuery.Deferred exception:$ .ajax不是函数TypeError:$ .ajax不是函数

jquery-3.1.1.slim.min.js:2 jQuery.Deferred exception: $.ajax is not a function TypeError: $.ajax is not a function

jquery-3.1.1.slim.min.js:2未捕获TypeError:$ .ajax是不是函数(...)

jquery-3.1.1.slim.min.js:2 Uncaught TypeError: $.ajax is not a function(…)

为什么?

推荐答案

jQuery 3 slim版本不支持ajax。

jQuery 3 slim version doesn't support ajax.

根据发布文档


除了包含ajax和
效果模块的常规jQuery版本外,我们还发布了一个瘦身版本,不包括这些
模块。总而言之,不包括ajax ,效果,以及目前
弃用的代码。

Along with the regular version of jQuery that includes the ajax and effects modules, we’re releasing a "slim" version that excludes these modules. All in all, it excludes ajax, effects, and currently deprecated code.

To使用 .ajax 方法,只需使用完整版本。

To use .ajax method, simply use the full version one.

这是工作小提琴

这篇关于jQuery 3 slim ajax基本示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆