When JSON passes a value, if there is a carriage return, it will hang up. We can use regularization to delete carriage returns:
2.HTML special character
After the data is transmitted from the server to the client in JSON format, some special characters can't be displayed directly when they are displayed on the HTML page through JSON, such as'
The solution is simple, just transform it before JS renders it as an HTML page:
3.escape () function
This function can handle spaces, slashes and any characters that may affect the browser, and convert them into Web-usable characters (for example, spaces will be converted into %20, and the browser will not treat them as spaces, but pass them directly to the server without making any changes). After that, the server will (usually automatically) convert them back to their original "look" after transmission.
4. The quotation mark problem
If JSON contains quotation marks or double quotation marks, the format of JSON will be destroyed. There are two ways to solve it.
When you put a string into storage, you can use the addslashes () function to process it and add a slash before the quotation marks. The changed characters include single quotation mark ('), double quotation mark ("), backslash (\) and empty characters.