added online check before ajax request