jQuery - .getjson VS .ajax json [duplicate]

2020-02-02 08:17发布

Possible Duplicate:
Difference Between $.getJSON() and $.ajax() in jQuery

super simple question.... between .getjson and .ajax() json which is faster?

considering retrieving and parsing data.

Much thanks.

标签: jquery ajax
4条回答
Summer. ? 凉城
2楼-- · 2020-02-02 08:34

I had a similiar question, and wanted to point out the following documentation in JQuery.ajax:

The $.ajax() function underlies all Ajax requests sent by jQuery. It is often unnecessary to directly call this function, as several higher-level alternatives like $.get() and .load() are available and are easier to use. If less common options are required, though, $.ajax() can be used more flexibly.

查看更多
倾城 Initia
3楼-- · 2020-02-02 08:36

.getjson() calls .ajax(), so they should be equivalent.

查看更多
够拽才男人
4楼-- · 2020-02-02 08:40

Same thing. getJSON() is a shorthand for .ajax(..) with specific parameters.

To quote the documentation of .getJSON():

This is a shorthand Ajax function, which is equivalent to:

   $.ajax({
      url: url,
      dataType: 'json',
      data: data,
      success: callback
    });
查看更多
混吃等死
5楼-- · 2020-02-02 08:47

jQuery.getJSON() uses the same jQuery.ajax() call finally, so there are no speed differences.

查看更多
登录 后发表回答