JQuery If Block problem

var htm = $ .ajax ({type: "GET", url: "./viewforms", async: false}) ResponseText ;.

var myObject = eval('(' + htm + ')');

alert(myObject.attributes[0]["type"]);

$("#updateDiv1").html(myObject.attributes[0]["type"]);
alert($("#updateDiv1").text());
l=$("#updateDiv1").text();
alert(l);
if(l =="String")
{
alert("if...");
}

      

In the above code, im restoring the values ​​from the database. I am getting the correct answer. Now I am comparing the return value of my database to String..ITs by reconfiguring the String, but I don't know why it is not included in the IF block. suggest me .....

0


a source to share


3 answers


Try trimming l

and then compare. http://www.somacon.com/p355.php



+2


a source


There may be additional characters such as space, space, carriage return, etc.



+1


a source


Try to put

$(document).ready(function() { 
  /* your code */
})

      

around your code.

0


a source







All Articles