[javascript] How to get data from database in javascript based on the value passed to the function