简体   繁体   English

如何使用javascript将postgres sql查询中的值分配给前端中的字段

[英]How To assign a value from postgres sql query to a field in frontend using javascript

I Actually Have 2 fields in the front end. 我实际上在前端有2个字段。 In which In the first field i will Auto Search the employee name for which I have Written A postgre sql query. 其中在第一个字段中,我将自动搜索我已写入postgre sql查询的员工姓名。

Now my Requirement Is As soon i select The Employee Name I need His job title To be Displayed in the next feild. 现在我的要求是我选择员工姓名我需要他的职位要在下一个领域显示。

How Can I do That Using Java Script. 我如何使用Java脚本执行此操作。 Please Find The Query below 请在下面找到查询

select ei.id,ei.employee_name,ro.name,um.role_id from manager_mapping mm 
left join employee_info ei on mm.typeid = ei.id  
left JOIN user_master um on um.id = ei.user_master_id   
left join role ro on ro.id = um.role_id   
where ei.employee_name ilike %:searchtxt% and ro.name='ROLE_JDM' or 
ro.name='ROLE_HEADOFF' and um.enabled = true 

In the Above Query I want the value the value of ro.name to be displayed automatically when i select the employee name 在上面的查询中,我希望在选择员工姓名时自动显示值ro.name

Create api and from front end using ajax or fetch call those api. 使用ajax或fetch调用那些api从前端创建api。 This api will internally call the service which will call the dao which will eventually run this query. 这个api将在内部调用service ,该service将调用将最终运行此查询的dao

Then send the result of the query as the return of the api . 然后将查询结果作为apireturn发送。 Once the ajax is successful you can assign the values to the variable in javascript 一旦ajax成功,您就可以在javascript中将值赋给变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM