- var json = null;
- if( xhr.getResponseHeader("Content-Type") == "application/json" ) {
- try {
- json = eval('(' + xhr.responseText + ')');
- }
- catch(e) {
- json = null;
+ if( xhr.readyState == 4 ) {
+ var json = null;
+ if( xhr.getResponseHeader("Content-Type") == "application/json" ) {
+ try {
+ json = eval('(' + xhr.responseText + ')');
+ }
+ catch(e) {
+ json = null;
+ }