最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

jquery中ajaxpost的使用

来源:动视网 责编:小采 时间:2020-11-27 20:31:26
文档

jquery中ajaxpost的使用

jquery中ajaxpost的使用:jQuery.post(url, [data], [callback], [type])概述通过远程 HTTP POST 请求载入信息。这是一个简单的 POST 请求功能以取代复杂 $.ajax 。请求成功时可调用回调函数。如果需要在出错时执行函数,请使用 $.ajax。参数url,[data],[call
推荐度:
导读jquery中ajaxpost的使用:jQuery.post(url, [data], [callback], [type])概述通过远程 HTTP POST 请求载入信息。这是一个简单的 POST 请求功能以取代复杂 $.ajax 。请求成功时可调用回调函数。如果需要在出错时执行函数,请使用 $.ajax。参数url,[data],[call


jQuery.post(url, [data], [callback], [type])

概述

通过远程 HTTP POST 请求载入信息。

这是一个简单的 POST 请求功能以取代复杂 $.ajax 。请求成功时可调用回调函数。如果需要在出错时执行函数,请使用 $.ajax。

参数

url,[data],[callback],[type]String,Map,Function,StringV1.0

url:发送请求地址。

data:待发送 Key/value 参数。

callback:发送成功时回调函数。

type:返回内容格式,xml, html, script, json, text, _default。

示例

1)向服务器传递数据数组(同时仍然忽略返回值):

jQuery 代码:

$.post("test.php", { 'choices[]': ["Jon", "Susan"] });

2)使用 ajax 请求发送表单数据:

jQuery 代码:

$.post("test.php", $("#testform").serialize());

3)向页面 test.php 发送数据,并输出结果(HTML 或 XML,取决于所返回的内容):

jQuery 代码:

$.post("test.php", { name: "John", time: "2pm" },
 function(data){
 alert("Data Loaded: " + data);
 });

4)获得 test.php 页面的内容,并存储为 XMLHttpResponse 对象,并通过 process() 这个 JavaScript 函数进行处理:

jQuery 代码:

$.post("test.php", { name: "John", time: "2pm" },
 function(data){
 process(data);
 }, "xml");

5)获得 test.php 页面返回的 json 格式的内容::

jQuery 代码:

$.post("test.php", { "func": "getNameAndTime" },
 function(data){
 alert(data.name); // John
 console.log(data.time); // 2pm
 }, "json");

文档

jquery中ajaxpost的使用

jquery中ajaxpost的使用:jQuery.post(url, [data], [callback], [type])概述通过远程 HTTP POST 请求载入信息。这是一个简单的 POST 请求功能以取代复杂 $.ajax 。请求成功时可调用回调函数。如果需要在出错时执行函数,请使用 $.ajax。参数url,[data],[call
推荐度:
标签: 使用 用法 实现
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top