replace the ajax function to callback