Does json add any overhead compared to returning raw html?

I have an ajax call that currently returns the raw html that I am inserting into the page.

Now my problem is that in some situations I need to return the count value along with the raw html, and if this count is> 10, I need to run another jquery operation to make something visible.

A better approach here would be to return json then correctly? Therefore, I can do:

jsonReturned.counter
jsonReturned.html

Do you agree?

Also, out of curiosity more than anything, is json a more expensive quality? This is a simple object with properties, but just asking.

+3
source share
4 answers

, , , JSON HTML. , (, , ).

, , JSON AJAX ( ) .

+3

, json - . , . , ? , . Javascript . .

+1

JSON, , , HTML, / , . {}/[], "" v.s. <a></a>. 2 . 7 - . , \, JSON .

0

  • JSON .
  • JSON.
  • HTML, JSON HTML .

The only way to find out if they are important to your application is to measure them. None of them are clearly large, and none of them is larger than O (n).

0
source

All Articles