Ajax post method form submission setRequestHeader error Solution
When we create an asynchronous object XMLHttpRequest and transmit data to the background in the post mode at the same time.
Set the value of the xhr. setRequestHeader Member of the asynchronous object
XMLHttpRequest. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded"); otherwise, the backend cannot receive the value passed in. It is shown in Google's compiler that the transfer value is in Request Payload. This is incorrect () -- check the attribute.
The correct method is in Form Data ()
This setting specifies how to encode the form data before it is sent to the server. There are three forms, which can be found in w3c documentation,
Example: <form enctype = "application/x-www-form-urlencoded"> </form>
There is a method serialize () in jquery .. The parameter can be set to a nest. Change to & name = "value"