title: jQuery AJAX call works on localhost not on live server
body: <p>I have a problem which I can't solve at the moment. 
  I have a WordPress AJAX login on my website from this example:
  <a href="http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way" rel="nofollow">http://natko.com/wordpress-ajax-login-without-a-plugin-the-right-way</a></p>
  
  <p>On my localhost everything is working fine and can login. On the live server I can't login and the response is always 0</p>
  
  <p>In my login.php I have this code:</p>
  
  <pre><code>function cted_ajax_login_init() {
  
  wp_register_script( 'ajax-login-js', get_template_directory_uri() . '/js/ajax-login.js', array('jquery') );
  wp_enqueue_script( 'ajax-login-js' );
  
  wp_localize_script( 'ajax-login-js', 'ajax_login_object', array(
      'ajaxurl'           =&gt; admin_url( 'admin-ajax.php' ),
      'redirecturl'       =&gt; $_SERVER['REQUEST_URI'],
      'loadingmessage'    =&gt; __('Gegevens verifiëren, een ogenblik ...')
  ));
  
  // Enable the user with no privileges to run ajax_login() in AJAX
  add_action( 'wp_ajax_nopriv_ajaxlogin', 'cted_ajax_login' );
  add_action( 'wp_ajax_ajaxlogin', 'cted_ajax_login' );
  }
  
  if ( !is_user_logged_in() ) {
  add_action( 'init', 'cted_ajax_login_init' );
  }
  </code></pre>
  
  <p>The ajax function: </p>
  
  <pre><code>function cted_ajax_login(){
  
  // First check the nonce, if it fails the function will break
  check_ajax_referer( 'ajax-login-nonce', 'security' );
  
  // Nonce is checked, get the POST data and sign user on
  $info = array();
  $info['user_login'] = $_POST['username'];
  $info['user_password'] = $_POST['password'];
  $info['remember'] = true;
  
  $user_signon = wp_signon( $info, false );
  
  if ( is_wp_error( $user_signon ) ) {
      $response = ( array(
          'loggedin'  =&gt; false,
          'message'   =&gt; __(),
          'error'    =&gt; $user_signon-&gt;get_error_message(),
      ) );
  } else {
      $response = ( array(
          'loggedin'  =&gt; true,
          'message'   =&gt; __(),
      ) );
  }
  
  wp_send_json( $response );
  
  }
  </code></pre>
  
  <p>And the jQuery</p>
  
  <pre><code>jQuery(document).ready(function($) {
  
  // Perform AJAX login on form submit
  $('form#login').on('submit', function(event){
  
      event.preventDefault();
  
      $('form#login p.status').show().text(ajax_login_object.loadingmessage);
  
      $.ajax({
          type: 'POST',
          dataType: 'json',
          url: ajax_login_object.ajaxurl,
          data: {
              action: 'ajaxlogin',
              username: $('form#login #username').val(),
              password: $('form#login #password').val(),
              security: $('form#login #security').val()
          },
          success: function(data) {
              console.log(data);
              $('form#login p.status').text(data.message);
              if(data.loggedin == true ) {
                   $('#loginmsg').addClass('bs-callout bs-callout-success');
                  document.location.href = ajax_login_object.redirecturl;
              }
              else {
                  $('#loginmsg').addClass('bs-callout bs-callout-danger');
              }
          },
          error: function(errorThrown){
              console.log(errorThrown);
          }
  
      });
  
  });
  
  });
  </code></pre>