i am trying to register in to my database but not able to send it in json format.I tried lot by searching and applying it on this code but no result is saving in database..How should i send data in json format .... sign_up_jump.js
// JavaScript Document
$('document').ready(function()
{
/* validation */
$("#signup").validate({
rules:
{
firstname: {
required: true,
minlength: 3
},
password: {
required: true,
minlength: 8,
maxlength: 15
},
passwordConfirmation: {
required: true,
equalTo: '#password'
},
email: {
required: true,
email: true
},
},
messages:
{
firstname: "please enter user name",
password:{
required: "please provide a password",
minlength: "password at least have 8 characters"
},
email: "please enter a valid email address",
passwordConfirmation:{
required: "please retype your password",
equalTo: "password doesn't match !"
}
},
submitHandler: submitForm
});
/* validation */
/* form submit */
function submitForm()
{
var data = $("#signup");
var data = JSON.stringify(data);
$.ajax({
type : 'post',
url : 'new_api.php',
data : data,
datatype: 'json',
beforeSend: function()
{
$("#error").fadeOut();
$("#submit").html('<span class="glyphicon glyphicon-transfer"></span> sending ...');
},
success : function(data)
{
if(data.result==1){
$("#error").fadeIn(1000, function(){
$("#error").html('<div class="alert alert-danger"> <span class="glyphicon glyphicon-info-sign"></span> Sorry email already taken !</div>');
$("#submit").html('<span class="glyphicon glyphicon-log-in"></span> Create Account');
});
}
else if(data.result =="registered")
{
$("#submit").html('<img src="btn-ajax-loader.gif" /> Signing Up ...');
setTimeout('$(".form-signin").fadeOut(500, function(){ $(".signin-form").load("login.php"); }); ',5000);
}
else{
$("#error").fadeIn(1000, function(){
$("#error").html('<div class="alert alert-danger"><span class="glyphicon glyphicon-info-sign"></span> '+data+' !</div>');
$("#submit").html('<span class="glyphicon glyphicon-log-in"></span> Create Account');
});
}
}
});
return false;
}
/* form submit */
});