bom dia,
Estou com um problema aqui que talvez deve ser a maior besteira mais eu estou apanhando muito. Estou em uma pagina onde o usuário digita alguma coisa e eu vou conecto em outro banco, e faço uma consulta em uma tabela com os dados que o usuário digitou ai blz… mais o que esta acontecendo é o seguinte a primeira vez que eu chamo isso ele traz a div fazia depois ele traz completa, isso no Firefox e o IE em isso… não traz nada de geito nem um… segue os códigos:
<script language="JavaScript" src='<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/jsp/view/js/jquery.js") %>'></script>
<script language="JavaScript" src='<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/jsp/view/js/facebox.js") %>'></script>
<script type="text/javascript">
function newXMLHttpRequest()
{
var xmlreq = false;
if (window.ActiveXObject)
{
// Cria o XMLHttpRequest via MS ActiveX
try
{
// Tenta criar o XMLHttpRequest em versões mais novas do IE
xmlreq = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e1)
{
// Impossível criar ActiveXObject
try
{
// Tenta uma versão suportada por versões mais antigas do IE
xmlreq = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e2)
{
alert('errou');
// Impossível criar um XMLHttpRequest com ActiveX
}
}
}
else if (window.XMLHttpRequest)
{
// Cria o XMLHttpRequest em browsers não-Microsoft
xmlreq = new XMLHttpRequest();
}
return xmlreq;
}
var ajaxRequest = null;
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox()
})
function divBackON() {
var indicadorCliente = document.getElementById("indicadorCliente").value;
if (indicadorCliente != "")
{
document.getElementById("divMsgDigitize").style.display = "none";
//document.getElementById("overlay").style.display="block";
if(ajaxRequest)
{
ajaxRequest.abort();
}
ajaxRequest = newXMLHttpRequest();
ajaxRequest.onreadystatechange = function()
{
// Se o status da requisição é "completo"
if (ajaxRequest.readyState == 4)
{
// Se a resposta do servidor foi bem-sucedida
if (ajaxRequest.status == 200)
{
alert('Antes do showDivIndicadores');
// Passa o XML da resposta à função handler
showDivIndicadores(ajaxRequest.responseXML)
}
else
{
// Se ocorreu um erro HTTP
alert("HTTP error: "+ajaxRequest.status);
}
}
};
ajaxRequest.open("POST", "<%= renderResponse.encodeURL(renderRequest.getContextPath() + "/indicadorClienteServlet")%>", true);
ajaxRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
var parametro = "indicadorCliente=" + indicadorCliente;
ajaxRequest.send(parametro);
} else {
document.getElementById("divMsgDigitize").style.display = "block";
}
}
function showDivIndicadores(xml){
var root = xml.getElementsByTagName('clients')[0];
var client = root.getElementsByTagName('client');
$("#tableSorter tbody").empty();
var t=setTimeout(populaCombo(client),2000);
alert ('Estou aqui no showDivIndicadores(xml){');
// populaCombo(client);
}
function populaCombo(client) {
alert ('Estou aqui no IE1');
for (var i = 0; i < client.length; i++) {
var newClient = client[i];
var id = newClient.getElementsByTagName('id')[0].firstChild.nodeValue;
var value = newClient.getElementsByTagName('name')[0].firstChild.nodeValue;
var radio = document.createElement('input');
radio.type ='radio'
radio.value = id;
radio.name = 'idCliente'
radio.onclick = saveClient(id);
var tr = document.createElement('tr');
var tdId = document.createElement('td');
var tdDescription = document.createElement('td');
var tbody = document.getElementById("tabletbody");
tdId.appendChild(radio);
tdDescription.innerHTML = value;
tr.appendChild(tdId);
tr.appendChild(tdDescription);
tbody.appendChild(tr);
//$("#tableSorter tbody").append(tr);
}
document.getElementById("ClientIndicadores").style.display = "block";
document.getElementById("overlay").style.display = "block";
alert ('Estou aqui no IE1');
}
function saveClient(id){
//alert(id);
}
</script>
<td><html:text property="userTO.indicadorCliente" value="" styleClass="form" size="25" styleId="indicadorCliente"/></td>
<td>
<div id="botaoPesquisar" style="display:none;">
<a rel="facebox" >
<bean:message key="userManagement.label.button.pesquisar"/></a>
</div>
</td>
<div id="overlay"></div>
<div id="ClientIndicadores" style="display:none; height:400px; width:500px;">
<div style="display:block;" class="subTitle">
<bean:message key="userManagement.message.name.clientoutside"/>
</div>
<div style="overflow:auto; height:330px; width:450px;">
<table id="tableSorter" class="tablesorter" cellpadding="0" cellspacing="0" align="center">
<thead>
<tr>
<th></th>
<th><bean:message key="userManagement.message.name.client"/></th>
</tr>
</thead>
<tbody id="tabletbody">
</tbody>
</table>
</div>
</div>
Alguma coisa que estiver comentado ou alert javascript foi eu tentando testar aqui no firefox e no IE e eu não consegui entender por que na primeira fez num monta nem a pau o tbody com o resoltado da consulta ai na seguinda vez vai…
mesmo não trasendo o resultado toda vez que eu click no butão que vai fazer a consulta chamando a função ajax ele sempre vai no servlet sempre mostra os logs do servlet.
por favor se alguem poder me ajudar serei muito granto…