jquery的.post和 ajax的区别是什么

提问者:雨的印记13 提问时间:2016年05月09日 人气:39
用户提问
ajax: jQuery.ajax( url [, settings ] ) url 类型: String 一个用来包含发送请求的URL字符串。 settings 类型: PlainObject 一个以"{键:值}"组成的AJAX 请求设置。所有选项都是可选的。可以使用$.ajaxSetup()设置任何默认参数。看jQuery.ajax( ...
推荐答案
ajax: 
    jQuery.ajax( url [, settings ] )
    url
    类型: String
    一个用来包含发送请求的URL字符串。
    settings
    类型: PlainObject
    一个以"{键:值}"组成的AJAX 请求设置。所有选项都是可选的。可以使用$.ajaxSetup()设置任何默认参数。看jQuery.ajax( settings )下所有设置的完整列表。
    例子:
    $.ajax({  accepts: {    mycustomtype: 'application/x-some-custom-type'  },   // Instructions for how to deserialize a `mycustomtype`  converters: {    'text mycustomtype': function(result) {      // Do Stuff      return newresult;    }  },   // Expect a `mycustomtype` back from server  dataType: 'mycustomtype'});
   
post:
    jQuery.post( url [, data ] [, success ] [, dataType ] )
    url
    类型:String
    一个包含发送请求的URL字符串.
    data
    类型:PlainObject or String
    一个普通对象或字符串,通过请求发送给服务器。
    success
    类型:Function( PlainObject data, String textStatus, jqXHR jqXHR )
    当请求成功后执行的回调函数。 如果提供dataType选项,那么这个success选项是必须的, 但这种情况下你可以使用null。
    dataType
    类型:String
    从服务器返回的预期的数据类型。默认:智能猜测(xml, json, script, text,html)。 
    例子:
    $.ajax({  type: "POST",  url: url,  data: data,  success: success,  dataType: dataType});