我在 jQuery ajax 请求中遇到问题。一旦我使用 ajax 作为 post 甚至 get 发送请求。它不断添加 NaNundefiened。 clearNaNgreen
[JavaScript];
$("#btnSubmit1").click(function() {
var criminality = $('select#criminality option:selected').val();
var color1 = $("select#color1 option:selected").val();
var business = $("select#business option:selected").val();
var color2 = $("select#color2 option:selected").val();
var civil = $("select#civil option:selected").val();
var color3 = $("select#color3 option:selected").val();
var bankruptcy = $("select#bankruptcy option:selected").val();
var color4 = $("select#color4 option:selected").val();
var education = $("select#education option:selected").val();
var color5 = $("select#color5 option:selected").val();
var candidateID = $("input#choosecandidate_hidden").val();
var dataString = 'criminality='+ criminality + '&color1=' + color1 + '&business=' + business
+ '&color2='+ color2 + '&civil=' + civil + '&color3=' + color3 + '&bankruptcy=' + bankruptcy+
+ '&color4='+ color4 + '&education=' + education + '&color5=' + color5+
+ '&report_status='+ report_status + '&color9=' + color9+'&report_form_name=report_form1&candidate_id='+candidateID;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "report_submit_ajax.php",
data: dataString,
success: function() {
alert('Form has been sumbmitted successfully');
}
});
return false;
});
[HTML]
<form id="report_form1" class="form" name="report_form">
<fieldset>
<legend>Executive Summary:</legend>
<table cellspacing="10" border="0">
<tbody>
<tr>
<td><b>Criminality/Integrity Check</b></td>
<td><select id="criminality" name="criminality">
<option value="clear">Clear</option>
<option value="verified">Verified</option>
<option value="verified_des_mijor">Verified with Major Discrepancy</option>
<option value="verified_des_minor">Verified with Minor Discrepancy</option>
</select></td>
<td><select id="color1" name="color1">
<option style="color: green;" value="green">Green</option>
<option style="color: blue;" value="blue">Blue</option>
<option style="color: yellow;" value="yellow">Yellow</option>
<option style="color: red;" value="red">Red</option>
</select></td>
</tr>
<tr>
<td><b>Highest Education Check</b></td>
<td><select id="education" name="education">
<option value="clear">Clear</option>
<option value="verified">Verified</option>
<option value="verified_des_mijor">Verified with Major Discrepancy</option>
<option value="verified_des_minor">Verified with Minor Discrepancy</option>
</select></td>
<td><select id="color5" name="color5">
<option style="color: green;" value="green">Green</option>
<option style="color: blue;" value="blue">Blue</option>
<option style="color: yellow;" value="yellow">Yellow</option>
<option style="color: red;" value="red">Red</option>
</select></td>
</tr>
<tr>
<td><b>Second Profession Reference Check</b></td>
<td><select id="employment_check_2" name="employment_check_2">
<option value="clear">Clear</option>
<option value="verified">Verified</option>
<option value="verified_des_mijor">Verified with Major Discrepancy</option>
<option value="verified_des_minor">Verified with Minor Discrepancy</option>
</select></td>
<td><select id="color7" name="color7">
<option style="color: green;" value="green">Green</option>
<option style="color: blue;" value="blue">Blue</option>
<option style="color: yellow;" value="yellow">Yellow</option>
<option style="color: red;" value="red">Red</option>
</select></td>
</tr>
<tr>
<td><b>Report Status</b></td>
<td><select id="report_status" name="report_status">
<option value="clear">Clear</option>
<option value="verified">Verified</option>
<option value="verified_des_mijor">Verified with Major Discrepancy</option>
<option value="verified_des_minor">Verified with Minor Discrepancy</option>
</select></td>
<td><select id="color9" name="color9">
<option style="color: green;" value="green">Green</option>
<option style="color: blue;" value="blue">Blue</option>
<option style="color: yellow;" value="yellow">Yellow</option>
<option style="color: red;" value="red">Red</option>
</select></td>
</tr>
</tbody>
</table>
</fieldset>
<input id="btnSubmit1" type="button" name="btnSubmit1" value="Update">
</form>
这是我得到的确切帖子
bankruptcy undefinedNaNundefined
business undefined
candidate_id 78
civil undefined
color1 green
color2 undefined
color3 undefined
color5 greenNaNundefined
color6 undefined
color8 undefinedNaNclear
color9 green
criminality clear
education clear
employment_check_2 clearNaNgreen
professional_reference undefined
report_form_name report_form1
如您所见,它生成了如此有趣的单词。有什么解决办法吗?