Я использую:
$.getJSON('addRecord.php', $('#addRecord').serialize())
для передачи данных JSON в функцию php через AJAX.Однако в дополнение к полям формы я получаю поле с именем '_', хотя я ничего не сделал для формы.Все поля формы имеют имена и идентификаторы, и после команды не так уж много.
Это код формы:
<form id='addRecord'>
<div class='form-group' id='coTypeIdD'>
<label for='coTypeId'>Type</label>
<input type='text' class='form-control' id='coTypeId' name='coTypeId' placeholder='Type'>
<small id='coTypeIdM' class='text-danger'></small>
</div>
<div class='form-group' id='coAccountIdD'>
<label for='coAccountId'>Account</label>
<input type='text' class='form-control' id='coAccountId' name='coAccountId' placeholder='Account'>
<small id='coAccountIdM' class='text-danger'></small>
</div>
<div class='form-group' id='coIsPrimaryD'>
<label for='coIsPrimary'>Primary?</label>
<input type='text' class='form-control' id='coIsPrimary' name='coIsPrimary' placeholder='Primary?'>
<small id='coIsPrimaryM' class='text-danger'></small>
</div>
<div class='form-group' id='coDescriptionD'>
<label for='coDescription'>Description</label>
<input type='text' class='form-control' id='coDescription' name='coDescription' placeholder='Description'>
<small id='coDescriptionM' class='text-danger'></small>
</div>
<div class='form-group' id='coUserD'>
<label for='coUser'>User</label>
<input type='text' class='form-control' id='coUser' name='coUser' placeholder='User'>
<small id='coUserM' class='text-danger'></small>
</div>
<div class='form-group' id='coSalutationD'>
<label for='coSalutation'>Salutation</label>
<input type='text' class='form-control' id='coSalutation' name='coSalutation' placeholder='Salutation'>
<small id='coSalutationM' class='text-danger'></small>
</div>
<div class='form-group' id='coFirstNameD'>
<label for='coFirstName'>First Name</label>
<input type='text' class='form-control' id='coFirstName' name='coFirstName' placeholder='First Name'>
<small id='coFirstNameM' class='text-danger'></small>
</div>
<div class='form-group' id='coLastNameD'>
<label for='coLastName'>Last Name</label>
<input type='text' class='form-control' id='coLastName' name='coLastName' placeholder='Last Name'>
<small id='coLastNameM' class='text-danger'></small>
</div>
<div class='form-group' id='coTitleD'>
<label for='coTitle'>Title</label>
<input type='text' class='form-control' id='coTitle' name='coTitle' placeholder='Title'>
<small id='coTitleM' class='text-danger'></small>
</div>
<div class='form-group' id='coDepartmentIdD'>
<label for='coDepartmentId'>Department</label>
<input type='text' class='form-control' id='coDepartmentId' name='coDepartmentId' placeholder='Department'>
<small id='coDepartmentIdM' class='text-danger'></small>
</div>
<div class='form-group' id='coPreferredCommunicationD'>
<label for='coPreferredCommunication'>Preferred Communication</label>
<input type='text' class='form-control' id='coPreferredCommunication' name='coPreferredCommunication' placeholder='Preferred Communication'>
<small id='coPreferredCommunicationM' class='text-danger'></small>
</div>
<div class='form-group' id='coPhoneD'>
<label for='coPhone'>Extension</label>
<input type='text' class='form-control' id='coPhone' name='coPhone' placeholder='Extension'>
<small id='coPhoneM' class='text-danger'></small>
</div>
<div class='form-group' id='coEmailD'>
<label for='coEmail'>Email</label>
<input type='text' class='form-control' id='coEmail' name='coEmail' placeholder='Email'>
<small id='coEmailM' class='text-danger'></small>
</div>
<div class='form-group' id='coMobileD'>
<label for='coMobile'>Mobile </label>
<input type='text' class='form-control' id='coMobile' name='coMobile' placeholder='Mobile '>
<small id='coMobileM' class='text-danger'></small>
</div>
<div class='form-group' id='coSkypeD'>
<label for='coSkype'>coSkype</label>
<input type='text' class='form-control' id='coSkype' name='coSkype' placeholder='coSkype'>
<small id='coSkypeM' class='text-danger'></small>
</div>
<div class='form-group' id='coFaxD'>
<label for='coFax'>coFax</label>
<input type='text' class='form-control' id='coFax' name='coFax' placeholder='coFax'>
<small id='coFaxM' class='text-danger'></small>
</div>
<div class='form-group' id='coPhone2D'>
<label for='coPhone2'>Alternate Phone</label>
<input type='text' class='form-control' id='coPhone2' name='coPhone2' placeholder='Alternate Phone'>
<small id='coPhone2M' class='text-danger'></small>
</div>
<div class='form-group' id='coBirthdateD'>
<label for='coBirthdate'>Birthday</label>
<input type='text' class='form-control' id='coBirthdate' name='coBirthdate' placeholder='Birthday'>
<small id='coBirthdateM' class='text-danger'></small>
</div>
</form>
И вот что я получаю, когда выкидываю$_GET
в PHP: