简体   繁体   English

在AJAX请求中使用更好的方法? $ .POST或$ .AJAX?

[英]better way to use in AJAX requests? $.POST or $.AJAX?

I have seen many articles for making ajax requests.. 我看过许多有关提出Ajax请求的文章。

most of them are using $.AJAX for jquery ajax posting and some of them are using $.POST for jquery ajax posting... 其中大多数使用$.AJAX进行jquery ajax发布,其中一些使用$.POST进行jquery ajax发布...

I want to know what is the best way if I want to post using ajax? 我想知道如果我想使用Ajax 发布最好的方法是什么? which method makes the ajax request fast and in lightweight? 哪种方法使ajax请求快速而轻量?

$.post is a shorthand way of using $.ajax for POST requests, so no difference. $.post是将$.ajax用于POST请求的$.ajax方法,因此没有区别。

$.ajax is generally better to use if you need some advanced configuration. 如果需要一些高级配置,通常最好使用$.ajax

$.post is just shorthand for $.ajax({type: 'POST'}) . $.post只是$.ajax({type: 'POST'})简写。 It makes no difference to the speed or weight of the request, just changes the readability of your code. 它对请求的速度或重量没有影响,只是改变了代码的可读性。

$.post只是$.ajax({ type: 'POST' }) [[ 请参见参考资料 ]]的简写,因此没有可接受的性能改进,但仍是可读性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM