views:

25

answers:

1

I have the following code working perfeclty in FireFox, but it won't work at all on IE6:

$("[name=servicos\\[\\]]").each( function() {
  this.checked = false;
  alert(this.name);
 }
);

$.getJSON("check_servicos.php?id=" + id, 
 function(data) {    
  $.each(data, 
   function(key, val) {
    alert($("#" + key).attr("id"));
    if(val > 0) $("#" + key).attr("checked", "checked");
   }
  )
 } 
);

Could anyone tell me what I'm missing, other than a way to forcefully upgrade all browsers at my job?

A: 

Check that check_servicos.php is setting the correct content-type for JSON (correct content-type is discussed here: http://stackoverflow.com/questions/477816/the-right-json-content-type).

I had a similar problem when trying to read XML and setting the content-type to "text/xml" solved my issue. I found the solution to my problem here: http://stackoverflow.com/questions/562283/jquery-find-doesnt-return-data-in-ie-but-does-in-firefox-and-chrome.

brainimus
That part worked fine on FireFox. On IE, something keeps the whole function from working. Even something as simple as alert("This is a test") inside the function isn't being called on IE6.
Carlos Negrão
Just confirmed that setting the correct content type doesn't work. The only thing like it I saw before was when my javascript had an error and FF would tell me the function I was trying to call didn't exists.
Carlos Negrão