Here I am using simple html+jquery+ajax file the ajax code is here
var email = "am3042208007@gmail.com";
var username = "ankur_07";
var password = "pass07";
var phone_no = "7676715797";
var datastring = {
"email": email,
"username": username,
"password": password,
"phone_no": phone_no
};
$.ajax({
type: "POST",
url: "../test/testreg.php",
data: {datastring : JSON.stringify(datastring)}, //with the page number as a parameter
dataType: 'html', //expect html to be returned
async: false,
success: function (data) {
alert(data);
/*if(data=="hello"){
message = "Mail Sent Successfully";
} else {
message = "Oops, mail doesn't send.!!!";
}
alert(message);*/
}
});
return false;
I am sending json from this file and ant to get in another testreg.php file
but it is not decoding json its showing as below line using in echo
{\"email\":\"am3042208007@gmail.com\",\"username\":\"ankur_07\",\"password\":\"pass07\",\"phone_no\":\"7676715797\"}
if(isset($_POST['datastring']))
{
$data = $_POST['datastring'];
$data = json_decode($data);
print_r($data);
}
please help me out of this stuck..