When the backend processes the data submitted by the front-end, you can either use form parsing or use JSON to parse the payload string.
Form parsing can get request parameters directly from the requests object, so that object conversion and processing is relatively easy, but when large chunks of JSON data need to be submitted, there may be a lot of data splitting and processing work, in addition to the collection type of processing, but also its weak place.
The advantage of payload is that a large number of JSON strings can be submitted at one time, but it is not possible to get parameters from request, but also to be limited to the depth of JSON parsing (especially with multi-layered object cascade, the lowest object can hardly be converted to concrete type).
In the case of Chrome, the network parameters they submit are as follows:
Form Submission Method:
Here's how payload is submitted:
specifically to the implementation, $.ajax default implementation is the form submission, the core lies in the ContentType settings, as follows:
vardata ={name:'ABC'};//Submit Data$.ajax ('app/', {method:'POST', //encode data into form modeContentType:'application/x-www-form-urlencoded; Charset=utf-8', //The data must be a JS object, not a stringData:data, Success:function (datas) {Console.log (datas)}})
The implementation of the payload submission method is as follows:
$.ajax ('app/', { //as far as I have tested, payload can only be used for post modeMethod'POST', //The data type must be a type other than application/x-www-form-urlencodedContentType:'Application/json;charset=utf-8', charset=utf-8', //data must be converted to a stringdata:JSON.stringify (data), Success:function (datas) {Console.log (datas)}})
Ajax form submission with payload submission