Bug in IE for some reason, with AJAX
Hi,
For some reason, when caling this function with only selected_id and field_num defined, we get this error (ONLY in IE ... tyical!)
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.30729; InfoPath.2; OfficeLiveConnector.1.3; OfficeLivePatch.0.0; .NET CLR 3.0.30729)
Timestamp: Wed, 10 Feb 2010 17:12:05 UTC
Message: 'optionValue' is null or not an object
Line: 452
Char: 10
Code: 0
URI:
https://domain.org/static/ajax.js
The code is:
- function update_existing_values(selected_id,next_selected_id,field_num) {
- if (next_selected_id) {
-
- jQuery.getJSON("/v.f" , { ajax_do: "wiki_ajax", id: selected_id, field: field_num - 1 }, function(j){
-
- var options = '';
- for (var i = 0; i <j.length; i++) {
- if (j[i].optionValue == next_selected_id) {
- options += '<option selected="yes" value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
- } else {
- options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
- }
- }
- jQuery("#article_is_in_" + field_num ).html(options);
- /* jQuery('#article_is_in_" + field_num + " option:first').attr('selected', 'selected');*/
- jQuery('#article_is_in_" + field_num + " option:first').attr('selected', 'selected');
- if (j.length > 1) {
- jQuery('#article' + field_num ).show();
- }
- })
- }
- }
The REALLY annoying bit, is that it works fine in FF, and Chrome. For some reason, when no results are passed back - it gives a fatal error.
Can anyone suggest a possible fix? I'm at my wits end with this one :(
TIA!
Andy