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

查看所有标签

Rapid Web Applications with TurboGears

Rapid Web Applications with TurboGears

Mark Ramm、Kevin Dangoor、Gigi Sayfan / Prentice Hall PTR / 2006-11-07 / USD 44.99

"Dear PHP, It's over between us. You can keep the kitchen sink, but I want my MVC. With TurboGears, I was able to shed the most heinous FileMaker Pro legacy 'solu-tion' imaginable. It has relationshi......一起来看看 《Rapid Web Applications with TurboGears》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HEX HSV 转换工具
HEX HSV 转换工具

HEX HSV 互换工具