title: ajax success returning 0
body: <p>I need a small help. I have designed my custom ajax function. It is a simple form which inputs 5 values validates them and then sends data through ajax to a php function and the function emails those details. Upon success a popup is shown to the user of confirmation.</p>
  
  <p>I have applied the validation and i am also able to run ajax. But for some reason my success function keeps on returning 0. Please help.</p>
  
  <p>Dev tools output on submit chrome:
  <a href="http://imgur.com/m5Ah0md" rel="nofollow">http://imgur.com/m5Ah0md</a></p>
  
  <p>Network output on submit on chrome:
  <a href="http://imgur.com/R7q9WnH" rel="nofollow">http://imgur.com/R7q9WnH</a></p>
  
  <p>My javascript</p>
  
  <pre><code>function contact_validations(){
  event.preventDefault();
  var name= jQuery('#contactname').val();
  var cemail= jQuery('#contactemail').val();
  var tel= jQuery('#contactphone').val();
  var address= jQuery('#contactaddress').val();
  var message= jQuery('#contactsubject').val();
  var s=true;
  
  if(name==''|| name==null ){
      jQuery('#name_err').html('Please enter your name');
      s=false;
      }else{  
          jQuery('#name_err').html('');
          }
  
  if(cemail==''){
      jQuery('#email_err').html('Please enter email');
      s=false;
      }else{ 
          var x=cemail;
          var atpos=x.indexOf("@");
          var dotpos=x.lastIndexOf(".");
          if (atpos&lt;1 || dotpos&lt;atpos+2 || dotpos+2&gt;=x.length)
              { jQuery('#email_err').html("Please Enter  Valid E-mail Address"); s= false;} 
              else{
                  jQuery('#email_err').html('');
                  }
          }   
  
  
  if(tel==''|| tel==null ){
      jQuery('#tel_err').html('Please enter your telephone number');
      s=false;
      }else{  
          jQuery('#tel_err').html('');
          }
  
  
  
  if(address=='' || address==null){
      jQuery('#address_err').html('Please enter your address');
      s=false;
      }else{  
          jQuery('#address_err').html('');
          }
  
  
  if(message=='' || message==null){
      jQuery('#message_err').html('Please enter your message');
      s=false;
      }else{  
          jQuery('#message_err').html('');
          }
          console.log( url );
  
  
  if(s)
          {
              var url = "http://localhost:9080/c/wp-admin/admin-ajax.php";
              var data = {
  
                  "action":"contact_email" ,
                  "name": name ,
                  "email": cemail ,
                  "tel": tel ,
                  "address": address ,
                  "message": message 
  
  
              }
              jQuery.ajax({
              type: "POST",
              url: url,   
              contentType: 'JSON',
              data: JSON.stringify(data),
              beforeSend: function(){
                  console.log('happened');
                  jQuery('#ajax-loader').show();
                  jQuery('#ajax-loader').html('&lt;img src="http://localhost:9080/c/wp-content/themes/aussie/images/ajax-loader.gif"&gt;');
                  },
              success: function(result) {
                  jQuery('#ajax-loader').hide();
                  console.log(result);
  
  
                  if(result=='0')
                  {
                      console.log("No Result")
                  }
                  if(result=='1')
                  {   
                  jQuery.fancybox({
                      href: '#contact-popup'
                  });
                  jQuery('#contactname').val('');
                  jQuery('#contactemail').val('');
                  jQuery('#contactphone').val('');
                  jQuery('#contactaddress').val('');
                  jQuery('#contactsubject').val('');
  
                  console.log ( s );
                } 
              }
          });
  
  
          }
  }
  </code></pre>
  
  <p>My Javascript:</p>
  
  <pre><code>function contact_email() {
  
  
  
              $url = get_bloginfo('url');
              $storeemail = get_option('contactemailstored'); 
              $to = $storeemail['contactemail'];
              $subject = $url . ' - Contact';
              $name = $_POST['contactname'];
              $email = $_POST['contactemail'];
              $phone = $_POST['contactphone'];
              $address= $_POST['contactaddress'];
              $content= $_POST['contactsubject'];                                         
              $message = '&lt;br&gt;'.'Name:- ' .  $name . '&lt;br&gt;';
              $message  .= 'Email- ' . $email . '&lt;br&gt;';
              $message  .= 'Phone:- ' . $phone . '&lt;br&gt;';
              $message  .= 'Address  :' . $address  . '&lt;br&gt;';
              $message  .= 'Subject  :' . $content  . '&lt;br&gt;';
  
  
              $sent_message = wp_mail( $to , $subject, $message ); 
  
          if ( $sent_message ) {
              // the message was sent...
              echo '1';
          } else {
              // the message was not sent...
              echo '1';
          }
  
           exit;
  
  
      }
  add_action('wp_ajax_contact_email', 'contact_email');
  
  add_action('wp_ajax_nopriv_contact_email', 'contact_email');
  </code></pre>