added function to post in javascript