Jump to content
  • 0

два XHR обьекта и их совместная работа


Jekel
 Share

Question

Не работает код, помогите исправить....Пожалуйста, подскажите в чем трабла....не выдает список вообще(

var XMLHttpRequestObject = false;

if (window.XMLHttpRequest){
XMLHttpRequestObject = new XMLHttpRequest();
} else if (window.ActiveXObject){
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
}

var XMLHttpRequestObject2 = false;

if (window.XMLHttpRequest2){
XMLHttpRequestObject2 = new XMLHttpRequest();
} else if (window.ActiveXObject){
XMLHttpRequestObject2 = new ActiveXObject("Microsoft.XMLHTTP");
}

function starto(){
if(XMLHttpRequestObject2){
XMLHttpRequestObject2.open("GET", "reset.php?data=0");
XMLHttpRequestObject2.onreadystatechange = function(){
if (XMLHttpRequestObject2.readyState == 4 && XMLHttpRequestObject2.status == 200){
var kololo = XMLHttpRequestObject2.responseText;
if(kololo=="1"){
getData();
}else{
starto();
}
}
}
XMLHttpRequestObject2.send(null);
}
}

function getData(){
if(XMLHttpRequestObject){
var obj = document.getElementById('pole');
XMLHttpRequestObject.open("GET", "konekt.php");

XMLHttpRequestObject.onreadystatechange = function(){
if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200){
obj.innerHTML = XMLHttpRequestObject.responseText;
starto();
}
}
XMLHttpRequestObject.send(null);
}
}

konekt.php

<?php 
session_start();
header('Content-Type: text/html; charset=windows-1251');
require_once "config.php";
mysql_connect($base_name, $base_user, $base_pass);
mysql_select_db($db_name);

$mybase = mysql_query("SELECT * FROM users WHERE online='1' AND id!='".$_SESSION['id']."'");
while($db2 = mysql_fetch_assoc($mybase)) {
$player = $db2['user']." (".$db2['rate'].")<br>";
echo $player;
}
?>

reset.php

<?php 
session_start();
header('Content-Type: text/html; charset=windows-1251');
require_once "config.php";
mysql_connect($base_name, $base_user, $base_pass);
mysql_select_db($db_name);

$mybase = mysql_query("SELECT * FROM users WHERE online='1'");
$db2 = mysql_num_rows($mybase);
if($_SESSION['num']!=$db2 && $_GET['data']=="0"){
$_SESSION['num'] = $db2;
$sho = "1";
}else{
$sho = "0";
}
echo $sho;
?>

Edited by Jekel
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy