ajax中类型和方法之间的差异是什么

Mr *_*ide 19 javascript methods ajax jquery post

我根据自己的经验使用了两种东西我在思考方法和类型都是POSTGET方法.

但看起来他们并不相似.

如果我使用type它正在工作我是serializeing一个表格数据..

如果我写method它不工作可以任何人解释他们之间的差异..?

$.ajax({
  url: "controller.php",
  type: 'POST',
  method: "POST",
  dataType: "json",
});
Run Code Online (Sandbox Code Playgroud)

帮助被挪用了.

Ste*_*lec 16

type(默认值:'GET')类型:String方法的别名.如果您使用的是1.9.0之前的jQuery版本,则应该使用type.

http://api.jquery.com/jquery.ajax/


Hos*_*sam 14

来自:http://api.jquery.com/jquery.ajax/

方法:

The HTTP method to use for the request (e.g. "POST", "GET", "PUT"). (version added: 1.9.0)
Run Code Online (Sandbox Code Playgroud)

类型:

An alias for method. You should use type if you're using versions of jQuery prior to 1.9.0.
Run Code Online (Sandbox Code Playgroud)


Sha*_*ale 5

两者都是相同的,在新版本的 jQuery 类型中重命名为方法