I have a similar problem stated in a separate post.
My php script is generating JSON for my jquery. I just used JSONLint and it stated that the JSON is valid.
Yet getJSON fails to return information using jQuery 1.4.2 yet it has been working in production for over a year now with jQuery 1.3.2.
Here is copy of my post:
I have a production webpage working fine for over a year now.
Recently, I wanted to upgrade to 1.4.2 in order to take advantage of the many new features.
For some reason, my getJSON is causing IE 7 to deliver the following error:
line 552
length is null or not an object
Firefox and Google Chrome also have the same problem.
In looking at the jQuery 1.3.2 and 1.4.2, there are differences in the getJSON code.
Why would something work nicely in 1.3.2 and crash in 1.4.2?
The only code change in my HTML code is the library.
Thanks.
Sammy
abcParsing
Microsoft Debugger Output
nodeName: function( elem, name ) {
return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
},
// args is for internal usage only
each: function( object, callback, args ) {
var name, i = 0,
length = object.length, //line 552 is this one
isObj = length === undefined || jQuery.isFunction(object);
if ( args ) {
if ( isObj ) {
for ( name in object ) {
if ( callback.apply( object[ name ], args ) === false ) {
break;
}
}
} else {
for ( ; i < length; ) {
if ( callback.apply( object[ i++ ], args ) === false ) {
break;
}
}
}
// A special, fast, case for the most common use of each
} else {
if ( isObj ) {
for ( name in object ) {
if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
break;
}
}
} else {
for ( var value = object[0];
i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
}
}
return object;
}
The getJSON Function is listed below.
$.getJSON(php_program, // 1st arg to getJSON is the URI of the script
{
test_category:test_category,
test_selected:test_selected,
noise:noise_value,
ph_noise:ph_noise_value,
cal:cal_value,
ph_cal:ph_cal_value,
qt:qt_value,
weeks_selected:[weeks_selected],
years_selected:[years_selected],
analysis_option:analysis_option,
aborted_runs_option: aborted_runs_option,
week_definition:week_definition,
rf_database_option:rf_database_option
},
function(wom) {
$.each(wom,function(i,j) {
//alert(j.wom+" "+j.header_and_results_noise_table);
//alert(j.wom+" "+j.header_and_results_ph_noise_table);
//alert(j.wom+" "+j.header_and_results_cal_table);
//alert(j.wom+" "+j.header_and_results_ph_cal_table);
//alert(j.wom+" "+j.header_and_results_qt_table);
//alert(j.wom+" Total Counter_Noise: "+j.ds0_total_cntr);
//alert(j.wom+" Total Counter_PH_Noise: "+j.ds1_total_cntr);
//alert(j.wom+" Total Counter_CAL: "+j.ds2_total_cntr);
//alert(j.wom+" Total Counter_PH_CAL: "+j.ds3_total_cntr);
//alert(j.wom+" Total Counter_QT: "+j.ds4_total_cntr);
noise_array.push([j.wom,j.Noise]);
ph_noise_array.push([j.wom,j.PH_Noise]);
cal_array.push([j.wom,j.Cal]);
ph_cal_array.push([j.wom,j.PH_Cal]);
qt_array.push([j.wom,j.QT]);
var index=j.wom + "_Noise";
noise_totals_array[index]=j.ds0_total_cntr;
index=j.wom + "_PH_Noise";
ph_noise_totals_array[index]=j.ds1_total_cntr;
index=j.wom + "_Cal";
cal_totals_array[index]=j.ds2_total_cntr;
index=j.wom + "_PH_Cal";
ph_cal_totals_array[index]=j.ds3_total_cntr;
index=j.wom + "_QT";
qt_totals_array[index]=j.ds4_total_cntr;
});
JSON Code Output with 1.3.2(Nothing gets printed with 1.4.2) Generated with php's json_encode
[{"wom":16,"Noise":57,"ds0_total_cntr":100,"PH_Noise":71,"ds1_total_cntr":99,"Cal":86,"ds2_total_cntr":100,"PH_Cal":36,"ds3_total_cntr":99,"QT":85,"ds4_total_cntr":100},{"wom":17,"Noise":47,"ds0_total_cntr":100,"PH_Noise":56,"ds1_total_cntr":100,"Cal":84,"ds2_total_cntr":100,"PH_Cal":36,"