博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
jQuery Ajax POST方法
阅读量:2519 次
发布时间:2019-05-11

本文共 2588 字,大约阅读时间需要 8 分钟。

Sends an asynchronous http POST request to load data from the server. Its general form is:

发送异步http POST请求以从服务器加载数据。 其一般形式为:

jQuery.post( url [, data ] [, success ] [, dataType ] )
  • url : is the only mandatory parameter. This string contains the adress to which to send the request. The returned data will be ignored if no other parameter is specified

    url:是唯一的必需参数。 此字符串包含向其发送请求的地址。 如果未指定其他参数,则将忽略返回的数据
  • data : A plain object or string that is sent to the server with the request.

    data:与请求一起发送到服务器的普通对象或字符串。
  • success : A callback function that is executed if the request succeeds.it takes as an argument the returned data. It is also passed the text status of the response.

    成功:如果请求成功执行的回调函数,它将返回的数据作为参数。 它还传递了响应的文本状态。
  • dataType : The type of data expected from the server. The default is Intelligent Guess (xml, json, script, text, html). if this parameter is provided, then the success callback must be provided as well.

    dataType:服务器期望的数据类型。 默认值为Intelligent Guess(xml,json,脚本,文本,html)。 如果提供了此参数,则还必须提供成功回调。

例子 (Examples)

$.post('http://example.com/form.php', {category:'client', type:'premium'});

requests form.php from the server, sending additional data and ignoring the returned result

从服务器请求form.php ,发送其他数据并忽略返回的结果

$.post('http://example.com/form.php', {category:'client', type:'premium'}, function(response){       alert("success");      $("#mypar").html(response.amount);});

requests form.php from the server, sending additional data and handling the returned response (json format). This example can be written in this format:

从服务器请求form.php ,发送其他数据并处理返回的响应(json格式)。 该示例可以用以下格式编写:

$.post('http://example.com/form.php', {category:'client', type:'premium'}).done(function(response){      alert("success");      $("#mypar").html(response.amount);});

The following example posts a form using Ajax and put results in a div

以下示例使用Ajax发布表单并将结果放入div中

  
jQuery.post demo

The following example use the github api to fetch the list of repositories of a user using jQuery.ajax() and put results in a div

以下示例使用github API使用jQuery.ajax()获取用户的存储库列表,并将结果放入div中

  
jQuery Get demo

jQuery.ajax() (jQuery.ajax())

$.post( url [, data ] [, success ] [, dataType ] ) is a shorthand Ajax function, equivalent to:

$.post( url [, data ] [, success ] [, dataType ] )是Ajax的简写功能,等效于:

$.ajax({  type: "POST",  url: url,  data: data,  success: success,  dataType: dataType});

$.ajax() provides way more options that can be found

$.ajax()提供了更多可以在找到的选项

更多信息: (More Information:)

For more information, please visit the

欲了解更多信息,请访问

翻译自:

转载地址:http://hmrwd.baihongyu.com/

你可能感兴趣的文章
Qt模态对话框和非模态对话框
查看>>
emacs 编译 如何把 emacs 的 el 文件编译为 elc 文件
查看>>
腾讯云云机安装dockers
查看>>
项目接口书写心得(1)
查看>>
Java学习(五)
查看>>
java获取整数的各位数值
查看>>
函数设计原则
查看>>
李叔同先生的《梦》
查看>>
azkaban hdfs plugin 配置
查看>>
vue2.0的ajax
查看>>
Promise预处理回调函数
查看>>
CSS 实现加载动画之二-圆环旋转
查看>>
sublime快捷键整理
查看>>
生产者消费者模型
查看>>
apiCloud 双击事件
查看>>
C#开发微信门户及应用(6)--微信门户菜单的管理操作
查看>>
查看变更(git diff)
查看>>
c++实现单向链表的一些操作
查看>>
Vim中无法用Alt键来映射
查看>>
ubuntu硬件配置查看命令
查看>>