Ajax return result correction and it's subsequent handling in js file