Why when sending data over AJAX, do you have to JSON.stringify() your objects?

前端 未结 3 2092
栀梦
栀梦 2020-12-06 18:44

JSON stands for javascript object notation (as I\'m sure you\'re aware), so why, when sending json via ajax do you need to turn it into a string to send it? Is it simply a f

3条回答
  •  [愿得一人]
    2020-12-06 19:29

    AJAX is all about HTTP requests, which are basically "text" requests to a server. That's the main reason why you have to stringify your object: That way it's turned into text that can "travel" over HTTP.

提交回复
热议问题