I have created an object which has the values of input elements in form. I have 3 pages in the form and i'm getting those pages using XMLHttpRequest. I need to send all those values to a php file and store them in variables of php file.Then i can insert them into the database.
I need to send these variables using XMLHttpRequest and POST method. So I used this code.
// obj1 is the object which stores the values of input fields
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if(xhr.readyState == 4 && xhr.status == 200 ) {
document.getElementById("newForm").innerHTML = xhr.responseText;
}
};
xhr.open("POST","Post Data.php", true);
xhr.setRequestHeader("Content-type", "multipart/form-data");
xhr.send("propertyX=obj1.property1");
}
It inserts nothing into the database.
This is the part of php file
$time = time();
$time = date("Y-m-d", $time);
$propertyX = $_POST["property1"];
Can anybody please help me to fix this?