开发者

jQuery - .getjson VS .ajax json [duplicate]

开发者 https://www.devze.com 2023-03-04 13:54 出处:网络
This question already has answers here: Closed 10 years ago. Possible Duplicate: Difference Between $.getJSON() an开发者_StackOverflow中文版d $.ajax() in jQuery
This question already has answers here: Closed 10 years ago.

Possible Duplicate:

Difference Between $.getJSON() an开发者_StackOverflow中文版d $.ajax() in jQuery

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

considering retrieving and parsing data.

Much thanks.


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


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
    });


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消