What is the difference between JSON and AJAX with jQuery?

前端 未结 4 1259
忘了有多久
忘了有多久 2021-01-31 06:04

I\'ve heard that JSON serializes all the data, which stops me having problems client side in terms of cross-browser support etc..

I\'ve been using AJAX with jQuery and i

相关标签:
4条回答
  • 2021-01-31 06:23

    I think you are confusing the terms.

    AJAX stands for Asynchronous Javascript and XML, which is a mechanism used to launch asynchronous HTTP requests to a server using JavaScript. Don't let the name fool you; there's no restriction on you only retrieving JavaScript or XML from this technique. You can quite happily return other data formats as well (HTML, plain text and JSON, to list a few).

    JSON is just one of these formats. It's a data interchange format, where-as AJAX is a technique to communicate with a server after the initate page load has completed.

    To answer your question on whether you need to specify the dataType; jQuery will best guess the response format (be it HTML or JSON etc), so you're usually fine to omit it.

    0 讨论(0)
  • 2021-01-31 06:24

    The dataType option simply changes what type of data jquery should expect from the server. It can be json, jsonp, html, text, xml, or any custom datatype that you define a converter for. They all work in all browsers.

    By default jQuery will try to detect what type of data is being returned if you do not supply a dataType option, however I find that it doesn't automatically detect very well.

    Edit:

    but what if i need to return an object? is basically the answer of a database consult... is it better to use json or only jquery?

    You can return an object in the form of html, xml, json, or jsonp. As long as it is in one of those formats, jQuery will be able to interpret it.

    0 讨论(0)
  • 2021-01-31 06:30

    Difference between JSON and AJAX could be determined into three layers.

    1. Language.

    2. Structure

    3. Designing

    Structure Designing

    0 讨论(0)
  • 2021-01-31 06:35

    JQuery: It is a light weight Javascript Library.

    JSON - Stands for JavaScript Object Notation.

    Jquery:It is created using JavaScript and you will be using the inbuilt functionalities from the library.

    Json: JSON is a text format that is completely language independent.

    JQuery:It is a fast and minified JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.

    Json: If you want assign data to Your grid then it is possible with Json.

    0 讨论(0)
提交回复
热议问题