jQuery ajax中的get请求方法汇总
2024-09-07 13:57:21
$.get()
Defination and Usage
从服务端以HTTP GET方式获取数据
Examples
请求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并且将返回的内容alert输出
$.get("test.php", function(data){
alert("Data: " + data);
});
Syntax
$.get(URL,data,function(data,status,xhr),dataType)
Parameter | Description |
---|---|
URL | 必须,指定你想请求的url地址 |
data | 可选,和请求一起发送给服务器的数据 |
function(data,status,xhr) | 可选,当请求成功后调用的函数 Additional parameters:
|
dataType | 可选,指定服务器希望返回的数据类型 默认的jQuery进行自动猜测 P可能的类型:
|
$.getJSON()
The getJSON()使用 AJAX HTTP GET 请求来获取JSON.
$(selector).getJSON(url,data,success(data,status,xhr))
$.getScript()
The getScript() 使用 AJAX HTTP GET 获取并指定一个Javascript
$(selector).getScript(url,success(response,status))
Parameter | Description |
---|---|
url | 必须,请求发送的Url地址 |
success(response,status) | 可选,指定运行成功之后的回调函数
|
最新文章
- OVER 分析函数
- PHPCMS V9教程之快速入门
- ZOJ3229 Shoot the Bullet(有源汇的上下界最大流)
- Dataguard之redo传输服务
- POJ2348+博弈
- exec与xargs区别
- 四种常见的 POST 提交数据方式--good
- POJ2676 Sudoku [数独]
- 去除VisualStudio中拼写错误检测的红色波浪线
- sitemap.xml 的 几个东西
- IP地址简介
- JavaScript之事件委托(附原生js和jQuery代码)
- Winform DevExpress控件库(二) 使用SplashScreenManager控件定制程序加载页面
- Spring的事务 之 9.1 数据库事务概述 ——跟我学spring3
- The account that is running SQL Server Setup does not have one or all of the following rights: the right to back up files and directories, the right to manage auditing and the security log and the rig
- Modbus库开发笔记:Modbus ASCII Master开发
- 学习笔记TF045:人工智能、深度学习、TensorFlow、比赛、公司
- MongoDB-数据&;权限管理(4)
- 微信小程序 weui 使用方法
- div实现返回符,倒三角,椭圆+小知识收集