Por favor, cualquiera puede ayudarme a obtener el valor de la matriz de campos de formulario y publicarlos usando ajax como envío de formulario
De campos como este: -
<input name="employment_Details[0][companyname]" > <input name="employment_Details[0][companyemail]" > <input name="employment_Details[0][companyphone]" > <input name="employment_Details[1][companyname]" > <input name="employment_Details[1][companyemail]" > <input name="employment_Details[1][companyphone]" >javascript va aquí :-
<script type="text/javascript"> var formdata = /* form data goes here i mean form fields value*/' Xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log(this.responseText); } }; xhttp.open("POST", "submit.php", true); xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhttp.send("form_submit=true&formdata=" + formdata); <script>php va aquí :-
<?php print_r($_POST['formdata']); ?> Results : Expected results look like this Array ( [0] => Array ( [companyname] => companyname goes here [companyemail] => companyemail goes here [companyphone] => companyphone goes here ) [1] => Array ( [companyname] => companyname goes here 1 [companyemail] => companyemail goes here 1 [companyphone] => companyphone goes here 1) )