0

Is there an advantage in using jQueries getJSON instead of jQuery.ajax?

Beside that it is shorter?

But exactly this shortage makes me think if it isn't risky to use getJSON.

If I later find out that I need one of the many options, which jQuery.ajax provides, I have to change a lot in my code.

With using the ajax.method I'm just adding one setting and finished.

So therefore my question:

Is getJSON used only for simplicity- and brevity-reasons? Or are there other advantages which I don't know yet?

ts248
  • 311
  • 1
  • 4
  • 11
  • yes, `getJSON` is used for simplicity, and for explicitly saying that you expect a json result, where it already is parsed to objects – devqon Apr 14 '16 at 08:21
  • `$.getJSON()` is just shorthand `$.ajax()`function so whats the confusion???? – Satpal Apr 14 '16 at 08:22
  • https://medium.com/@KDweber89/ajax-vs-getjson-ca910fa6854e#.aqpwhhpdg – KieranDotCo Apr 14 '16 at 08:22
  • @Satpal That's exactly my question. Is it just a shorthand or is there something else what I don't know? If there isn't anything else, then it is answered now because: Yes, it is just a shorthand. – ts248 Apr 14 '16 at 08:26
  • http://api.jquery.com/jquery.getjson/ – Satpal Apr 14 '16 at 08:28
  • 1
    `$.getJSON()` gets text AND parses it to a json object with `$.parseJSON()`. So it returns a JSON object rather than text. – Pierre C. Apr 14 '16 at 08:32
  • 1
    You're over-thinking this. But if you're really concerned the source code for all of jQuery is freely available so you can easily see exactly what getJSON() does. – nnnnnn Apr 14 '16 at 08:32

0 Answers0