Hi,
i am doing a password reset form using Jquery and PHP
if i try to submit an email id it should sent and email and report back the response text as success so that the user knows email has been sent.
But i am stuck with JSON submit as i have an empty array to decode at the serverside.
I am using minified version of json2.js from the official json.org website
Here is the code.
var formdata = $("#log-box").serializeArray();
formdata = JSON.stringify(formdata);
var notifymsg;
alert(formdata);
$.ajax({
type: "POST",
url: "forgot-pass.php",
contentType: 'application/json',
data: formdata,
success: function(responsedata){
var some = responsedata.split("&");
$.each(some, function(index,value){
//alert("index="+index+"value="+value);
});
},
error: function(o, s, e){
alert("Form not posted \
"+e);
}
});
formdata alerted gives:
[{“name":“email”,“value”:"ravi.k@gmail.com”},{“name”:“acctype”,“value”:“loginaccount”}]
PHP forgot-pass.php
print_r($_POST);
gives me
Array
(
)
Can someone point out what i might be doing wrong? i am a designer and this is the first time i am trying to do JSON