Q:

JSON variable is not passed to ajax function

Here is the Ajax Code. I am using this ajax code to pass the details to the php page and the php file is supposed to return an array value as true or false depending on the condition. I have used json_encode but it doesn't seem to work
 $.ajax({
      url: "join_form.php",
      type: "POST",
      dataType: 'json',
      data: {
        name: name,
        email: email,
        contact: contact,
        role: role,
        dialcode: dialcode,
        countrycode: countrycode
      },
      cache: false,
      // var data = JSON.parse(data);
      success: function(data) {
      data = $.parseJSON(data);
      console.log(data);
      if(data.status == 'false')
      {
        alert("Something went wrong");
      }
      else
      {
        alert("Message submitted successfully");
        $("#joinForm").trigger("reset");
      }
            // alert(dialcode+countrycode);

        }

        });
    $("#joinForm").trigger("reset");

  });

Here is the Php file (join_form.php). 
This php file checks for validity of fields and stores a false value
 in the 
array on which I use json_encode function so that it can
 be returned to ajax. But on returning nothing happens.
 It shows blank function.
 if else functions are not executed. Please help
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "kites";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
    alert("Connection failed");
}
else
{
$response = array();
// Check for empty fields
if(
      empty($_POST['name'])     || 
      empty($_POST['email'])    ||
      empty($_POST['contact'])  ||
      empty($_POST['role']) ||
      empty($_POST['dialcode']) ||
      empty($_POST['countrycode'])  
   )

{
  echo "No arguments Provided!";
  $response['status']='false';
}

else{
   $name = $_POST['name'];
   $email = $_POST['email'];
   $contact = $_POST['contact'];
   $role = $_POST['role'];
   $dialcode = $_POST['dialcode'];
   $countrycode = $_POST['countrycode'];

$stmt = $this->conn->prepare("SELECT email from join_form WHERE email = ?");

        $stmt->bind_param("s", $email);

        $stmt->execute();

        $stmt->store_result();

        if ($stmt->num_rows > 0) {
            // user existed 
            // $stmt->close();
            $response['status'] = 'false';
        } else {
            // user not existed
            // $stmt->close();
            $response['status'] = 'true';
        }
header("Content-Type: application/json; charset=utf-8", true);
echo json_encode($response);

$sql = "INSERT INTO join_form (name,email,contact,role,dialcode,countrycode)
VALUES ('$name','$email','$contact','$role','$dialcode','$countrycode')";

 if (mysqli_query($conn, $sql)) {
       $response['status'] = 'true';
} 
else {    
    echo "Please do it again";
    $response['status'] = 'false';
    // echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
    header("Content-Type: application/json; charset=utf-8", true);
  echo json_encode($response);

}
}     
?>

A:

Remove all the un-needed echos from your php, and keep only the last one 'echo json_encode($response);'.
Than you don't need to parse the returned response in your ajax call. So you will get your status and you can do something with it.
Alternatively if you wnat also to return the messages you are echoing than you can do the following:
$response['status'] = 'false';
$response['message'] = 'No arguments Provided!';

echo json_encode(response).

And than in your ajax call response:
if(data.status == 'false')
  {
    alert(data.message);
  }
}

NOTE: remove the 'HEADER's from your php, you also don't need this. In the ajax call you have set 'data-type = json' and this is enough. The data will be sent back with the appropriate headers automatically!
You are passing the variable to your your data:
data: {
        name: name,
        email: email,
        contact: contact,
        role: role,
        dialcode: dialcode,
        countrycode: countrycode
      },

from where do you get those values?
If they are coming from a form you will need to refer to them:
var name = $('#name').val()
... and so on.

Maybe you already did that but You are not posting your complete code n order to give me the possibility to spot your problem. And by the way, down voting the answer before you will post the complete code in here don't really help.
If you don't post also your HTML I can not see that.
NOTE: You answer with a 'Nothing worked' doesn't really help, and you don't mention the errors you are eventually receiving, so I still have to guess.

