changed POST request to JavaScript and some other changes