I had problem to refresh my list, I will do send parameter to servlet
when I do with hyperlink I will do like this.
<a href="ServletTransaksi?action=refresh">Refresh table</a>
I use scriptlet. How can I refresh my list without clicked something.
thanks
You can use Javascript, and bind an AJAX request to any page. For example, when the page loads, you can add the code.
Example
document.addEventListener("load", function () {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4) {
if (xmlhttp.status == 200) {
// Your request has gone through.
}
}
}
xmlhttp.open("GET", "ServletTransaksi?action=refresh", true);
xmlhttp.send();
}, false);
On page load, this will make a request to the server and refresh the table. You can add code where i've commented saying // Your request has gone through
.
NOTE: This code does not use any jQuery, and is written in completely original Javascript. I've never understood the logic in pulling down the whole jQuery toolkit, if you're only going to be making AJAX requests with it.
Extra Reading
Firstly, read up on AJAX so you know what is going on. You can read here: http://www.codeproject.com/Articles/14142/AJAX-Explained
Secondly, I would look into the different types of events you can bind with Javascript. These are available here: http://www.w3schools.com/js/js_events.asp