Added beforeOpen option to ajax.