Reputation: 1
This is my first post. I have searched for other solutions and what I've found only deals with components of this question. Basically this is what I'd like to do:
Bellow is the code I'm using. But first, here are some alternatives I've tried. Usually I get this: array(0) { }
var_dump($_POST), var_dump($_GET), var_dump($_REQUEST).
var serialisedForm = $(form).serializeArray();
var serialisedData = JSON.stringify(serialisedForm);
console.log(serialisedData); //working
console.log(serialisedForm); //working
$.ajax({
type: "POST",
url: "datacapture.php",
data: {
serialisedForm, //tested using serialisedData as well
},
success: function() {
window.open('datacapture.php');
},
error: function() {
alert("the form data has not been sent to the server");
}
})
and here is the datacapture.php script I'm using to test the information flow.
<?php
var_dump($_POST);
?>
EDIT - and here is a sample form item, reading .text and .name from my settings.json file:
<tbody>
{
this.props.settings.schemes[0].questions.map((q, i)=> {
return <tr><td>{q.text}</td><td><div class="YesNo"><input type="radio" required name={q.name} value="yes">Yes</input><input type="radio" required name={q.name} value="no">No</input></div></td></tr>
})
}
</tbody>
Upvotes: 0
Views: 1651
Reputation: 1
just change 1seralisedForm1 to 1seralisedData1 it will return an json object to php which can be seen by doing:
echo json_decode($_POST);
Upvotes: 0