[jQuery] Re: Json works in firefox but not in ie
Common problem. It was blogged about in Feb last year (http://grover.open2space.com/node/207). Still, I'm glad you found the solution. Shawn Patrik wrote: Problem solved it was an extra , after the last {optionValue: '". $b ."', optionDisplay: '". $b ."'} in the php file. firefox must have ignored it while ie expected more. On 19 Okt, 16:49, Greg Riley wrote: You are setting options inside a function and then trying to reference it outside of that function. Try putting var options = ''; before that first line. On Oct 19, 10:22 am, Patrik wrote: Hi, I have this code and it works well in firefox but in IE it dosn't. How do I make it work in IE? If I put alert(options) inside the loop I get all the values I want so this far it's working but outside the loop if i call alert(options) nothing happens. why? $("select#kod").change(function(){ $.getJSON("artnr-ajax.php",{value: $(this).val(), where: 'kod'}, function(j){ var options = ''; for (var i = 0; i < j.length; i++) { options += '' + j [i].optionDisplay + ''; } $("select#beteckning").html(options); })
[jQuery] Re: Json works in firefox but not in ie
Problem solved it was an extra , after the last {optionValue: '". $b ."', optionDisplay: '". $b ."'} in the php file. firefox must have ignored it while ie expected more. On 19 Okt, 16:49, Greg Riley wrote: > You are setting options inside a function and then trying to reference > it outside of that function. > > Try putting var options = ''; before that first line. > > On Oct 19, 10:22 am, Patrik wrote: > > > Hi, > > I have this code and it works well in firefox but in IE it dosn't. > > How do I make it work in IE? > > If I put alert(options) inside the loop I get all the values I want so > > this far it's working but outside the loop if i call alert(options) > > nothing happens. why? > > > $("select#kod").change(function(){ > > $.getJSON("artnr-ajax.php",{value: $(this).val(), where: 'kod'}, > > function(j){ > > var options = ''; > > for (var i = 0; i < j.length; i++) { > > options += '' + j > > [i].optionDisplay + ''; > > } > > $("select#beteckning").html(options); > > > })
[jQuery] Re: Json works in firefox but not in ie
Thanks but it didnt help and the reference is inside of the funktion missed to put }) }) in my message. nothing inside the getJSON function will work after the closing } in the for loop if i put alert("after"); won't show or anything else. On 19 Okt, 16:49, Greg Riley wrote: > You are setting options inside a function and then trying to reference > it outside of that function. > > Try putting var options = ''; before that first line. > > On Oct 19, 10:22 am, Patrik wrote: > > > Hi, > > I have this code and it works well in firefox but in IE it dosn't. > > How do I make it work in IE? > > If I put alert(options) inside the loop I get all the values I want so > > this far it's working but outside the loop if i call alert(options) > > nothing happens. why? > > > $("select#kod").change(function(){ > > $.getJSON("artnr-ajax.php",{value: $(this).val(), where: 'kod'}, > > function(j){ > > var options = ''; > > for (var i = 0; i < j.length; i++) { > > options += '' + j > > [i].optionDisplay + ''; > > } > > $("select#beteckning").html(options); > > > })
[jQuery] Re: Json works in firefox but not in ie
You are setting options inside a function and then trying to reference it outside of that function. Try putting var options = ''; before that first line. On Oct 19, 10:22 am, Patrik wrote: > Hi, > I have this code and it works well in firefox but in IE it dosn't. > How do I make it work in IE? > If I put alert(options) inside the loop I get all the values I want so > this far it's working but outside the loop if i call alert(options) > nothing happens. why? > > $("select#kod").change(function(){ > $.getJSON("artnr-ajax.php",{value: $(this).val(), where: 'kod'}, > function(j){ > var options = ''; > for (var i = 0; i < j.length; i++) { > options += '' + j > [i].optionDisplay + ''; > } > $("select#beteckning").html(options); > > })