Javascript string comparison and extension checking
<p>I am using jquery $.ajax() function to read a text file to retrieve the content inside which is a file name.</p>

<p>I have returned a string "FYP Final Report.pdf" and I am going to check if this is a pdf file.</p>

<p>I am using the following code:</p>

<pre><code>var url = result[i]['url'];  (**The string returned by $.ajax() using "JSON" as dataType)

function getExt(file){
return file.split(".").pop();
}
if(getExt(url) == "pdf"){
 do sth;
}else{
 do another thing;
}
</code></pre>

<p>I have alert the returned text which is really "FYP Final Report.pdf" and the typeof(url) also returns string type. However I can never get into the do sth part unless I hard coded url into "FYP Final Report.pdf"</p>

<p>Is there anything i missed that makes the string returned differs from hard coded "FYP Final Report.pdf"?
Thanks very much</p>
