Q: how to send the form data to server in json format in ajax javascript function ajax() {
  $('form').submit(function() {
    console.log($(this).serializeArray());
    $('#result').text(JSON.stringify($(this).serializeArray()));
    return false;
  });
}

This is the json data i'm getting:
[{"name":"firstName","value":"erere"},{"name":"lastName","value":"rere"},{"name":"emailAddress","value":"eregedfd@gmail.com"},{"name":"password","value":"dfdfd"},{"name":"phoneNumber","value":"989989898"}]

How can I send it to the server. What should I include in data in the ajax call?

A: A simple example:
$('form').submit(function() {

    $.post( "send.php", $(this).serializeArray())
      .done(function( reply ) {
        alert( "Complete, reply from server: " + reply );
      });

    return false;
});

See: http://api.jquery.com/jquery.post/ for information on handling callbacks.

A: Try this:
$('form').submit(function() {
    var form = $(this);
    var data = form.serialize();

    $.ajax({
        url: 'post url'
        method: 'POST',
        data: data,
        success: function(resp){
             //action on successful post
        },
        error: function() {
            //handle error
        }
    });
    return false;
});

