jQuery get() 方法
jQuery 教程
· 2019-03-28 13:19:27
实例
发送一个 HTTP GET 请求到页面并取回结果:
$("button").click(function(){
$.get("demo_test.html",function(data,status){
alert("Data: " + data + "nStatus: " + status);
});
});
定义和用法
$.get() 方法使用 HTTP GET 请求从服务器加载数据。
实例
请求 "test.php",但是忽略返回结果:
$.get("test.php");
请求 "test.php" 并连同请求发送一些额外的数据(忽略返回结果):
$.get("test.php", { name:"Donald", town:"Ducktown" });
请求 "test.php" 并传递数据数组到服务器(忽略返回结果):
$.get("test.php", { 'colors[]' : ["Red","Green","Blue"] });
请求 "test.php" 并提醒请求的结果:
$.get("test.php", function(data){
alert("Data: " + data);
});语法
$.get(URL,data,function(data,status,xhr),dataType)
| 参数 | 描述 |
|---|---|
| URL | 必需。规定您需要请求的 URL。 |
| data | 可选。规定连同请求发送到服务器的数据。 |
| function(data,status,xhr) |
可选。规定当请求成功时运行的函数。 额外的参数:
|
| dataType |
可选。规定预期的服务器响应的数据类型。 默认地,jQuery 会智能判断。 可能的类型:
|
点击查看所有 jQuery 教程 文章: https://www.codercto.com/courses/l/35.html
The Creative Curve
Allen Gannett / Knopf Doubleday Publishing Group / 2018-6-12
Big data entrepreneur Allen Gannett overturns the mythology around creative genius, and reveals the science and secrets behind achieving breakout commercial success in any field. We have been s......一起来看看 《The Creative Curve》 这本书的介绍吧!
HTML 压缩/解压工具
在线压缩/解压 HTML 代码
JSON 在线解析
在线 JSON 格式化工具