Getting some weird results with jQuery / PHP / MySQL
<p>I'm having trouble getting the expected result.</p>

<p>I have the following jQuery script:</p>

<pre><code>   // obj is the return result of another query
  jQuery.post("mypath/include/jquery_bll.php", { instance: 'controllAccess', brandID: obj.id },
  function(data)
  {
    if (jQuery('#brand_selectList').length == 0)
    {
      if (data == "Locked")
      {
        jQuery('#countryListBox').attr('disabled','true');
      }
    }
  }, "text");
</code></pre>

<p>So what this does, is to disable select box if return result = "Locked".</p>

<p>Here is my PHP code that returns the result:</p>

<pre><code> function controllBrandRelation($dal)
  {
    // Get label data.
    $result = $dal-&gt;getRowByValue('myTable','id', $_POST['someID']);

    if (mysql_num_rows($result) &gt; 0)
    {
      while ($row = mysql_fetch_array($result))
      {
        $ownerID = $row["fk_userID"];    
      }
    }

    if(!empty($ownerID))
     echo 'Locked';
    else
      echo 'Open';       
  }
</code></pre>

<p>This will return 'Locked' if $ownerID has some values.</p>

<p><strong>This is my problem:</strong><br />
If I do an <code>alert(data.length)</code>, I get the result 72. I really should be getting 6, which is the number of characters in the word 'Locked'.</p>

<pre><code>  jQuery.post("mypath/include/jquery_bll.php", { instance: 'controllAccess', brandID: obj.id },
  function(data)
  {
    alert(data.length);
  }
</code></pre>

<p>If I do an <code>alert(jQuery.trim(data).length)</code>, I get the correct value.</p>

<p>But whatever I do, I'm not able to get inside this IF test:</p>

<pre><code>  if (data == "Locked")
  {
    jQuery('#countryListBox').attr('disabled','true');
  }
</code></pre>

<p>Why is data not equal "Locked"?</p>

<p>I've tested with both the trimmed and untrimed version.</p>

<p><strong>UPDATE</strong><br /></p>

<p>I've managed to get it working by changing return results from text to json.
So now I check on if <code>(data.status == "locked")</code>, and it works fine.</p>

<p>But I really would like to know how the return results for text is 76 characters long, when it should be 6. And why I'm not able to match/test the result.</p>
