$.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:

  • data - 请求返回的结果数据
  • status - 请求的状态("success", "notmodified", "error", "timeout", or "parsererror")
  • xhr - 包含XMLHttpRequest对象
dataType 可选,指定服务器希望返回的数据类型

默认的jQuery进行自动猜测

P可能的类型:

  • "xml" - An XML document
  • "html" - 作为普通文本的HTML
  • "text" - 一个普通文本字符串
  • "script" - 将response作为javascript运行,作为普通文本返会
  • "json" - 将response作为JSON运行,并且返回的是javascript对象
  • "jsonp" - 使用JSONP在JSON块中加载,量在url后面加上"?callback=?" 来指定回调函数callback

$.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) 可选,指定运行成功之后的回调函数

  • response - 包含从请求返回的结果数据
  • status - 包含请求的状态("success", "notmodified", "error", "timeout", or "parsererror")

最新文章

  1. OVER 分析函数
  2. PHPCMS V9教程之快速入门
  3. ZOJ3229 Shoot the Bullet(有源汇的上下界最大流)
  4. Dataguard之redo传输服务
  5. POJ2348+博弈
  6. exec与xargs区别
  7. 四种常见的 POST 提交数据方式--good
  8. POJ2676 Sudoku [数独]
  9. 去除VisualStudio中拼写错误检测的红色波浪线
  10. sitemap.xml 的 几个东西
  11. IP地址简介
  12. JavaScript之事件委托(附原生js和jQuery代码)
  13. Winform DevExpress控件库(二) 使用SplashScreenManager控件定制程序加载页面
  14. Spring的事务 之 9.1 数据库事务概述 ——跟我学spring3
  15. 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
  16. Modbus库开发笔记:Modbus ASCII Master开发
  17. 学习笔记TF045:人工智能、深度学习、TensorFlow、比赛、公司
  18. MongoDB-数据&权限管理(4)
  19. 微信小程序 weui 使用方法
  20. div实现返回符,倒三角,椭圆+小知识收集

热门文章

  1. python--文本处理1
  2. Android 检查输入
  3. DevExpress右键菜单使用 z
  4. Mingw/Code::Block/wxWidgets 搭建
  5. solr 最佳实践
  6. 微信小程序日期定位弹出框遮挡问题
  7. php如何读取ini文件
  8. JavaScript闭包其一:闭包概论 函数式编程中一些基本定义
  9. Android 设计模式之单例模式
  10. 看完此文,妈妈还会担心你docker入不了门?