IDVsbruck, )) Сори, я просто решил, что это проблемы гденибудь в кеше IE или еще в какойто такой его особенности, которая к коду не должна относится, потому что в Firefox вобще все хорошо, а IE в первый раз отрабатывает, а потом возвращает всю туже xml-ку, что в первый раз. Вот начальный файл: | Код | <table style="width:220px;"> <tr> <td width="50px"><div id="redstar"><table><tr> <td><img src="/vote/starred.gif" width="10" height="10" onmouseover="this.src='/vote/starred2.gif'; document.getElementById('voice').innerHTML='-5';" onmouseout="this.src='/vote/starred.gif'; document.getElementById('voice').innerHTML=preVoice;" onclick="voitfunc(-5, '<?= $table?>', '<?= $_GET["id"]?>', '<?=$_SESSION["user_name"]?>');" /></td> <td><img src="/vote/starred.gif" width="10" height="10" onmouseover="this.src='/vote/starred2.gif'; document.getElementById('voice').innerHTML='-4';" onmouseout="this.src='/vote/starred.gif'; document.getElementById('voice').innerHTML=preVoice;" /></td> <td><img src="/vote/starred.gif" width="10" height="10" onmouseover="this.src='/vote/starred2.gif'; document.getElementById('voice').innerHTML='-3';" onmouseout="this.src='/vote/starred.gif'; document.getElementById('voice').innerHTML=preVoice;" /></td> <td><img src="/vote/starred.gif" width="10" height="10" onmouseover="this.src='/vote/starred2.gif'; document.getElementById('voice').innerHTML='-2';" onmouseout="this.src='/vote/starred.gif'; document.getElementById('voice').innerHTML=preVoice;" /></td> <td><img src="/vote/starred.gif" width="10" height="10" onmouseover="this.src='/vote/starred2.gif'; document.getElementById('voice').innerHTML='-1';" onmouseout="this.src='/vote/starred.gif'; document.getElementById('voice').innerHTML=preVoice;" /></td></tr></table> </div></td> <td style="width:50px;"><div id="voice" class=story align="center"></div></td> <td width="50px"><div id="greenstar"><table><tr> <td><img src="/vote/star.gif" width="10" height="10" onmouseover="this.src='/vote/star2.gif'; document.getElementById('voice').innerHTML='+1';" onmouseout="this.src='/vote/star.gif'; document.getElementById('voice').innerHTML=preVoice;" /></td> <td><img src="/vote/star.gif" width="10" height="10" onmouseover="this.src='/vote/star2.gif'; document.getElementById('voice').innerHTML='+2';" onmouseout="this.src='/vote/star.gif'; document.getElementById('voice').innerHTML=preVoice;" /></td> <td><img src="/vote/star.gif" width="10" height="10" onmouseover="this.src='/vote/star2.gif'; document.getElementById('voice').innerHTML='+3';" onmouseout="this.src='/vote/star.gif'; document.getElementById('voice').innerHTML=preVoice;" /></td> <td><img src="/vote/star.gif" width="10" height="10" onmouseover="this.src='/vote/star2.gif'; document.getElementById('voice').innerHTML='+4';" onmouseout="this.src='/vote/star.gif'; document.getElementById('voice').innerHTML=preVoice;" /></td> <td><img src="/vote/star.gif" width="10" height="10" onmouseover="this.src='/vote/star2.gif'; document.getElementById('voice').innerHTML='+5';" onmouseout="this.src='/vote/star.gif'; document.getElementById('voice').innerHTML=preVoice;" /></td></tr></table> </div></td> </tr> </table> <div id="mess"></div> <script> var preVoice=document.getElementById('voice').innerHTML; </script>
|
Вот JS: | Код | var xmlHttp = createXmlHttpRequestObject();
function createXmlHttpRequestObject() { var xmlHttp; if (window.ActiveXObject) { try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { return false; } } else { try { return new XMLHttpRequest(); } catch (e) { return false; } } if(!xmlHttp) alert("Ошибка создания объекста XMLHttpRequest"); return false; }
function voitfunc(ball, table, trick_id, session_user_name) { // Продолжать если xmlHttp не пустая строчка if (xmlHttp) { // Попытаться установить соедиенение с сервером try { if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0) { // name = encodeURIComponent(document.getElementById("myName").value); xmlHttp.open("GET", "/vote/votexml.php?ball="+ball+"&table="+table+"&id="+trick_id+"&sun="+session_user_name, true); // document.getElementById("divMessage").innerHTML ="vote/votexml.php?ball="+ball+"&table="+table+"&id="+trick_id; xmlHttp.onreadystatechange = handleServerResponse; // alert("/vote/votexml.php?ball="+ball+"&table="+table+"&id="+trick_id+"&sun="+session_user_name); xmlHttp.send(null); } else { setTimeout('voitfunc(ball, table, trick_id, session_user_name)', 1000); } } catch (e) { alert("Не удалось установить соединение с сервером: "+e); } } }
function handleServerResponse() { if (xmlHttp.readyState == 4) { if (xmlHttp.status == 200) { var xmlResponse = xmlHttp.responseXML; xmlDocumentElement = xmlResponse.documentElement; currentRatio = xmlDocumentElement.getElementsByTagName("ratio").item(0).firstChild.data; document.getElementById("voice").innerHTML = currentRatio; alert(xmlHttp.responseText); document.getElementById("mess").innerHTML=xmlDocumentElement.getElementsByTagName("base").item(0).firstChild.data; preVoice=currentRatio; } else { alert("При обращении к серверу возникли проблемы: "+xmlHttp.statusText); } } }
|
И php который возвращает xml: | Код | <?php header('Content-Type: text/xml'); echo '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>'; echo "<response>"; include_once("../conf.inc.php"); include_once("../class_sql.php"); $sql = new sql(); $sql->server = $mysqladress; $sql->login = $user_name; $sql->pass = $user_pass; $sql->db = $db_name; $result_ratio_select=0;
require_once("../class_controlpanel.php"); $obj_ctrlp = new control_panel(); require_once("../class_filemgr.php"); $obj_filemgr = new filemgr; $table=$_GET["table"];
if($sql->connect() == -1){ $err = 'init: \$sql->connect() returns -1'; } if($sql->select_db() == -1){ $err = 'init: \$sql->select_db() returns -1'; } if ($_GET["sun"]) { // echo "<ratio>".$_GET["id"]."</ratio>"; $result_ratio_select = $obj_filemgr->select_file_info($table, $_GET["id"], "ratio"); $array[0]["key"] = "ratio"; $array[0]["value"] = $obj_filemgr->select_file_info($table, $_GET["id"], "ratio") + $_GET["ball"]; if (($sql->update($table, $array, " WHERE (id='".$_GET["id"]."')")) != -1) { echo "<ratio>".$obj_filemgr->select_file_info($table, $_GET["id"], "ratio")."</ratio>"; echo "<base>".$result_ratio_select."</base>"; } else { echo "<ratio>Err</ratio>"; } } echo "</response>"; ?>
|
Это сообщение отредактировал(а) AJIeKceu_D - 10.6.2008, 18:00
|