Ajax error

If you can not access the background ajax method corresponding controller directly error, first check the url access path, if not the wrong path, then use Google developer tools to run about, whether there is a basic grammar errors, such as wrong character, one more one less comma,

If the surface front-end no problem, do not call back Mapping and error method, most of the value of the error string of key-value pairs of data it or did not get the corresponding value, or pass a character type is not on the past, or passed by value and the value of the background @RequestParam not on, I made a mistake yesterday, ajax can run, return status has not been a success, and there is no response back, tangled wonder for a long time, because one of the input is radio, I direct $ ( "gender"). val ( ), get out of the value is wrong, you should use

var gender=$("input[name='gender']:checked").val();

The following is a method to get the value of radio

var val=$('input:radio[name="sex"]:checked').val();

Three methods are attached:

$('input:radio:checked').val();
   
$("input[type='radio']:checked").val();

$("input[name='rd']:checked").val();





Guess you like

Origin www.cnblogs.com/codeByWei/p/10987805.html