Using javascript
How to access the data base using java script.
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suraj SahooPosted Jan 13, 2015, 3:33 AM
Some what like below:
$.ajax({url:"/CONTROLLER/ACTION",
type:"GET" //since you are fetching(POST if you are posting/sending data to server),
success: function(data){ //here data is the records fetched from db/server
$("#ANYID").html(data);
}
});
This would help you access database from javascript. Remember by default ajax call is asynchronous, to make it synchronous add
async:false inside ajax call.
I hope this helps.
Thanks.
Murugesh PPosted Jan 7, 2015, 8:11 AM
You can use Ajax method to access your Data Access Layer, which in turn access data base.