This error occurs when the object is null or undefined when you want to acces a property.
var x = undefined;
var y = null;
alert(x.pop); // error
alert(x.pop); // error
If you want to check if the object is null you can just do:
if (response) {
// Do stuff
}
If you want to check if the object property exists you can do:
if (response) {
var value = response.responeText || defaultValue
}
Edit: From the comments:
There's a few ways for checking for something being defined, but if (something) or var x = y || z; is not the way to go because falsey values (0, '', etc.) would cause this to not work. If you want to see if something is defined, I would use if (typeof x === "undefined"). For checking for a property in an object, I would use if (x in obj), or possibly better depending on the scenario - if (obj.hasOwnProperty(x)). And for checking for null, I would use if (x == null)