tags:

views:

15

answers:

1

I have this simple attacched code, I can get right text on the first debug alert but the search and if condition doesn't work, what is wrong in my code? Or there is a better way to do the same?

thanks in advance

ciao h

$.post("./php/piattaforma.php",
{azione:"valida_pia", contratto:contratto},
 function(xml)
  {
$(xml).find("sel_mess").each(function()
{
 var messaggio=$(this).text();
 alert(messaggio);
 var str=messaggio.search("text");
 if (str!=-1)
 {
 alert("ok");
 }
 });
    },"xml"
    );
+1  A: 

This should work. Got capital letters in the word text? If so use

 var str=messaggio.search(/text/i);
Mark Baijens
Ok perfect! Thanks!
haltman