fixes some issues in jquery ajax method