jQuery load() 方法

jQuery 教程 · 2019-03-28 16:56:34

实例

把文件 "demo_test.txt" 的内容加载到指定的 <div> 元素:

$("button").click(function(){ $("#div1").load("demo_test.txt"); });

定义和用法

load() 方法从服务器加载数据,并把返回的数据放置到指定的元素中。

注意:还存在一个名为 load 的 jQuery 事件方法。调用哪个,取决于参数。

语法

$(selector).load(url,data,function(response,status,xhr))

参数 描述
url 必需。规定您需要加载的 URL。
data 可选。规定连同请求发送到服务器的数据。
function(response,status,xhr) 可选。规定 load() 方法完成时运行的回调函数。

额外的参数:
  • response - 包含来自请求的结果数据
  • status - 包含请求的状态("success"、"notmodified"、"error"、"timeout"、"parsererror")
  • xhr - 包含 XMLHttpRequest 对象

点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html

查看所有标签

The Book of CSS3

The Book of CSS3

Peter Gasston / No Starch Press / 2011-5-13 / USD 34.95

CSS3 is the technology behind most of the eye-catching visuals on the Web today, but the official documentation can be dry and hard to follow. Luckily, The Book of CSS3 distills the heady technical la......一起来看看 《The Book of CSS3》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

在线进制转换器
在线进制转换器

各进制数互转换器

html转js在线工具
html转js在线工具

html转js在线工具