Problems with Get encountered:
1. Question one. Caching: When each access URL is the same, the client directly reads the contents of the local cache, even if the background data changes the foreground will not change;
Solution: In? The following link is a num= "random number Math.random ()" or num= "timestamp new Date (). GetTime ()", ' 1.php?username= ' May ' & ' +num (there are no variable names here, avoid conflicts with background parameters)
2. Question two. Garbled, when the transmission of Chinese or special characters, the foreground appears garbled
Solution: Using coded encodeURI (' snail ')
Test results: By using the chrome test, both problems with the result get have been solved
Issues encountered using Post:
Post method, the data is placed in the Send () as a parameter transfer;
Problem: When the request header is not set, the background directly does not process the data, the foreground will not be able to obtain background data returned
Workaround: Manually set the request header (Xhr.setrequestheader (' Content-type ', ' application/x-www-form-urlencoded ')) to declare the data type sent
"Note" Post does not have a caching problem, there is no coding problem (because it has been declared in the request header)
Test results: By using the chrome test, the result post this does not declare the header information, the problem exists
Simply put: The difference between a GET request and a POST request
1. When using a GET request, the parameter is displayed in the URL and the Post method is not displayed
2. Use GET request to send the data quantity is small, the POST request sends the data quantity to be big
The above is a small set to introduce the Ajax in the use of Get and post encountered problems and solutions, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!