IT Band of Brothers JavaWeb parameter passing problem in AJAX Tutorial

When sending a GET request using Ajax and parameters need to pass directly splicing parameters in the URL address in the following format:

xhr.open ( 'get', 'path request parameter name parameter value 1 = 1 2 & parameter name parameter value = 2 ...?', true);

When sending POSt request using Ajax and need to pass parameters, can be spliced ​​parameters so and send GET request is not immediately after the URL address difference may also pass parameters in the send process, but is recommended to use the send method parameter passing and require special settings request header, Content-Type is set URL encoding, the following format:

xhr.setRequestHeader('Content-Type','applilication/x-www-form-urlencoded');

xhr.send ( '1 = parameter name parameter value of the parameter name 1 & 2 = Value 2 ...');

Guess you like

Origin blog.csdn.net/weixin_33738555/article/details/90863592