ajax wrapper undefined check

added check if xhr object is not null or undefined