This article is a mirror article of machine translation, please click here to jump to the original article.

View: 18429|Reply: 0

[Jquery] jQuery Ajax forces all content-types to be modified

[Copy link]
Posted on 3/5/2021 1:54:34 PM | | |
Requirements: Due to the project upgrade, the backend architecture has changed, and the Content-Type of all Ajax request POSTs needs to be modified.
application/x-www-form-urlencoded; charset=UTF-8 to application/json; charset=UTF-8


1. First, determine whether it is a POST request;
2. Determine whether the data in POST is of type json string, and the first character at the beginning is { or [;
3. Determine whether the current Content-Type contains: x-www-form-urlencoded

The code is as follows:








Previous:Consul HTTP API interface call
Next:Newcomer report post
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com