By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,625 Members | 1,448 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,625 IT Pros & Developers. It's quick & easy.

refresh jsp with ajax

P: 8
Hi all,

I have a jsp page and i use the <display:table> in it.
I want to refresh the table but not all page.
I use AJAX for this operation.But I can't refrest the table.How can I post the table data to jsp during refresh...

Please help...
Thanks...
Nov 20 '07 #1
Share this Question
Share on Google+
5 Replies


acoder
Expert Mod 15k+
P: 16,027
Can you post your AJAX code?
Nov 21 '07 #2

P: 8
this is my jsp code;
[HTML]

var page = "doktor.do?dispatch=dene";
function ajax(url,target)
{
// native XMLHttpRequest object
document.getElementById(target).innerHTML='<div align="center"><br /><br /><img src="loading.gif"><br />Ykleniyor..</div>';
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = function() {ajaxDone(target);};
req.open("GET", url, true);
req.send(null);
// IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = function() {ajaxDone(target);};
req.open("GET", url, true);
req.send();
}
}
setTimeout("ajax(page,'randevu')", 10000);
}function ajaxDone(target) {
// only if req is "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200 || req.status == 304) {
results = req.responseText;
document.getElementById(target).innerHTML = results;
} else {
document.getElementById(target).innerHTML="ajax error:\n" +
req.statusText;
}
}
}


</script>
</HEAD>
<body background="<%=request.getContextPath()%>/images/bck.gif"
bgcolor="#FFFFFF" text="#000000" link="#800000" vlink="#FF0000"
alink="#800000" leftmargin="0" topmargin="0" marginwidth="0" onLoad="ajax(page,'randevu');">

..........................


<div id="randevu">
<table width="100%">
<tr>
<TD>
<display:table width="100%" id="row" cellpadding="2px" pagesize="15" border="1" styleClass="TABLE.asd" name="randevuDTO2" requestURI="doktor.do?dispatch=giris">
<display:column width="50%" title="Hasta" property="hastaAd" href="doktor.do?dispatch=buldum" paramId="randevuID" paramProperty="randevuID"></display:column>
<display:column title="Saat" property="saat"/>
<display:column title="Durum" property="durum" />

<display:setProperty value="" name="basic.msg.empty_list"/>
<display:setProperty value="Bir kayıt bulunmuştur." name = "paging.banner.one_item_found"/>
<display:setProperty name="sort.amount" value="list" /> <!-- t羹m listeyi kendi i癟inde s覺ralad覺ktan sonra paginge sokar -->
<display:setProperty name="paging.banner.group_size" value="3" /><!-- altta link olarak g繹sterilecek sayfa say覺s覺 -->
<display:setProperty name="paging.banner.some_items_found" value="<FONT color='navy'><br>{0} Kayıt Bulundu...{2}-{3} Arası Kayıtlar<br> </FONT>" /><!-- Sayfalama mesaj覺 -->
<display:setProperty name="paging.banner.full" value="<FONT color='navy'><a href={1}>&lt&lt</a> <a href={2}>&lt</a> {0} <a href={3}>&gt</a> <a href={4}>&gt&gt</a></FONT>" /><!--sayfalama linkleri;ilk yada sonda de?ilken -->
<display:setProperty name="paging.banner.first" value="<FONT color='navy'>&lt&lt &lt {0} <a href={3}>&gt</a> <a href={4}>&gt&gt</a></FONT>" /><!--sayfalama linkleri;ilk kay覺tttayken-->
<display:setProperty name="paging.banner.last" value="<FONT color='navy'><a href={1}>&lt&lt</a> <a href={2}>&lt</a> {0} &gt &gt&gt" /><!--sayfalama linkleri;son kay覺ttayken-->
<display:setProperty name="paging.banner.all_items_found" value="<FONT color='navy'><br>{0} Kayıt Bulundu...Sayfa </FONT>"></display:setProperty>
<display:setProperty name="paging.banner.placement" value="bottom" />
<display:setProperty name="paging.banner.some_items_found" value="{0} tane kayit ..."/>
</display:table>

</TD>
</TR>
</table>
</div>
[/HTML]

-------------------------------------
I can't post the table elements back from action:(
Nov 21 '07 #3

acoder
Expert Mod 15k+
P: 16,027
If you want to send the table data, you will need to add the data as parameters with the URL, e.g. "url?param1="+tabledata1+"&param2="+tabledata2 ...
Nov 21 '07 #4

P: 8
ok I will do that.
how can I send the table back at java code?
Nov 21 '07 #5

acoder
Expert Mod 15k+
P: 16,027
ok I will do that.
how can I send the table back at java code?
You do that with your server-side code.

You can either return HTML and just replace everything or XML/JSON and parse the response.
Nov 21 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.