Click here to Skip to main content
15,884,917 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
dear sir,

i want to do fire a simple select query in javascript.

plz help.
Posted
Comments
Raje_ 9-Jul-14 2:18am    
There is no direct way. You have to use Ajax. :)
Rajkumar_007 9-Jul-14 2:41am    
Thank you Raje

No, you cannot. You client-side script has no access to the database directly. The closest is via Ajax call, but it still has to go through a server-aide script like php which in turns handles the database operation.
Ajax example[^]
 
Share this answer
 
v2
Comments
Rajkumar_007 9-Jul-14 2:40am    
Thank you Peter Leow :)
Javascript is a client side language means it wont access the database.

So you need to use php or any server side language to access the database.

If you use ajax it will fetch data from db without refreshing the page.
 
Share this answer
 
If the data that you want to query is not a very huge data then you can try doing the below:

1) Create an asp file that will fetch the data and write it into an htmltable
2) Include that asp file in your parent file
3) Use document.getElementByID to query that htmltable for the data you want

Please do not try this for very huge data queries as this will make your page heavy. You can also use it for table like master entries - that do not change often
 
Share this answer
 
Comments
Rajkumar_007 12-Jul-14 4:06am    
thank you Gauri Chodanker :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900