jquery+get(.java)方法_jQuery get()方法

jQuery get()方法

get()方法是jQuery中的内置函数。它使用HTTP GET请求从服务器加载数据。它用于发出简单的GET请求。它返回XMLHttpRequest对象。

句法

参数值

此方法包括四个参数值,其中一个是必需的,其他是可选的。我们必须将URL参数包含在get()方法中。下表定义了get()方法的参数值。

Parameter

Values

URL

It is the URL to which the request is sent. It is a mandatory parameter.

data

It is an optional parameter. It is data sent to the server along with the request. It can be a plain object or a string.

function(data, status, xhr)

This is also an optional parameter. It is a callback function that executes on the successful server request.

It also has three parameters that are data, status, and xhr in which data contains the resulting data from the request, status represents the request status like “success”, “error”, etc., and the xhr contains the XMLHttpRequest object.

dataType

This is also an optional parameter that defines the type of data we are expecting from the server. The type can be “text”, “json”, “jsonp”, “html”, “script”, and “XML”.

现在,让我们看一个使用get()方法的简单示例。

在此示例中,我们通过使用get()方法发出一个get请求。我们使用get()方法的两个参数,即URL和回调函数。

URL参数设置为值test.html。我们使用回调函数的两个参数,分别是data和status,其中第一个参数保存请求页面的数据,第二个参数保存请求状态。

在输出中,我们可以看到从服务器加载的数据,并且请求的状态为成功。

test.html

Example2.html

输出量

执行完上述代码后,输出将为-

jquery-get-method.png

点击给定的按钮后,输出将是-

jquery-get-method2.png

0

相关文章:jQuery-选择器 jQuery-选择器 jQuery库利& […]...

jQuery-Whatsnearby.js jQuery-Whatsnearby.js Whatsnearby.js是一 […]...

jQuery选择器 jQuery选择器 jQuery选择器用于选择和操作HTML元素。它们是jQuery库的重要组成部分。 使用j […]...

jQuery before() jQuery before() jQuery before()方法用于将指定的内容插入所选元素之前。它将参数指 […]...

jQuery addClass() jQuery addClass() addclass()方法用于将一个或多个类名称添加到所选元素。此方法仅用于 […]...

jQuery unWrap() jQuery unwrap() jQuery unwrap()方法用于删除所选元素的父元素。 句法:...

jQuery keydown() jQuery keydown() 当您按下键盘上的一个键时,会发生keydown()事件,并且一旦发生keyd […]...

jQuery Extend()方法 jQuery extend()方法 jQueryextend()方法将两个或更多对象的内容合并到第一个对象中。 […]...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值