title: JQuery/Ajax accepting True/False from PHP function
body: <pre><code>function check_jobref_availability(){
      if ($job_reference_already_exists == 0) { 
          $output = TRUE;
      } else {
          $output = FALSE;
      }
      echo $output;
  }
  </code></pre>
  
  <p><strong>complete function</strong> </p>
  
  <pre><code>function check_jobref_availability(){       
      $output = 1;       
      $jobrefference = $this-&gt;uri-&gt;segment(3); //mysql_real_escape_string($_REQUEST['ptitle']);
      $strSQL = "SELECT count(*) FROM projects where ptitle = '" . $jobrefference . "' and companyid = 1";
      $job_reference_already_exists = get_singlecolumn($strSQL);        
  
      //if it is zero means. no refrence was found and it is good to go to add the new job reference.
      if ($job_reference_already_exists == 0) { 
          $output = 1; // NOT FOUND SO GO AHED 
      } else {
          $output = 0; // MEANS ALREAYD EXISTS give an alert
      }
      echo $output;
  </code></pre>
  
  <p>}</p>
  
  <p>This is my PHP Code (rest of the code actually queries the DB) and returns 0 or 1. Based on which i need to return true or false.</p>
  
  <pre><code>var newjobrefrence = $('#newjobrefrence').val().trim();
  $.ajax(
  {
      type: "POST",
      url: "&lt;?php echo base_url(); ?&gt;postproject/check_jobref_availability/" + newjobrefrence,        
      data: {ptitle: newjobrefrence},
      success: function(response){
          if (response.d == "false") {
              jobrefrencealreadyexists = 1;
              alert("Job ref found");
  
          }else{
             jobrefrencealreadyexists = 0;
             alert("Not found");
          }
  
      },
      error: function(xhr, ajaxOptions, thrownError) {
          alert(xhr.status);
          alert(thrownError);
      }
  });
  </code></pre>
  
  <p>And this is my jquery/ajax call. I am new to jquery/ajax.</p>
  
  <p>All it needs to do is call check_jobref_availability, and based on the return value do an alert.</p>
  
  <p>I have tried different combinations like returning Jason (I am not 100% sure if was doing that correctly either), or returning "True" or "False" and simple true; and false; but I can not see the response in my jquery..</p>
  
  <p>I have got few hair left on my head as I have been pulling them all weekend on this. </p>
  
  <p>Any help would be much appreciated to save my hair style.</p>