jQuery getJSON() 方法

jQuery 教程 · 2019-03-28 13:39:02

实例

使用 Ajax 请求获取 JSON 数据,并输出结果:

$(document).ready(function(){ $("button").click(function(){ $.getJSON("demo_ajax_json.js",function(result){ $.each(result, function(i, field){ $("div").append(field + " "); }); }); }); });

定义和用法

getJSON() 方法使用 AJAX 的 HTTP GET 请求获取 JSON 数据。

语法

$(selector).getJSON(url,data,success(data,status,xhr))

参数 描述
url 必需。规定将请求发送到哪个 URL。
data 可选。规定发送到服务器的数据。
success(data,status,xhr) 可选。规定当请求成功时运行的函数。
额外的参数:
  • data - 包含从服务器返回的数据
  • status - 包含请求的状态("success"、"notmodified"、"error"、"timeout"、"parsererror")
  • xhr - 包含 XMLHttpRequest 对象

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

查看所有标签

Algorithms in C, Parts 1-4

Algorithms in C, Parts 1-4

Robert Sedgewick / Addison-Wesley Professional / 1997-9-27 / USD 89.99

"This is an eminently readable book which an ordinary programmer, unskilled in mathematical analysis and wary of theoretical algorithms, ought to be able to pick up and get a lot out of.." - Steve Sum......一起来看看 《Algorithms in C, Parts 1-4》 这本书的介绍吧!

RGB转16进制工具
RGB转16进制工具

RGB HEX 互转工具

XML 在线格式化
XML 在线格式化

在线 XML 格式化压缩工具

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具