Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [JS] Zwraca null i wywala całą strone?, Za indywidualną pomoc zapłacę :)
SethSeth
post 8.07.2017, 13:49:14
Post #1





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 8.07.2017

Ostrzeżenie: (0%)
-----


Cześć mam taki kod nie napisany przezemnie z góry uprzedzam znam się na javascript tak 2/10
Co chwile wywala mi wartość null

Oto kod błędu
Kod
Uncaught TypeError: Cannot read property 'getElementsByTagName' of null
    at drawMessages (Functions.js:182)
    at TConnection.onTournamentLoaded [as onData] (lineupload.js:169)
    at TConnection.<anonymous> (Functions.js:86)
    at XMLHttpRequest.<anonymous> (Functions.js:276)



Oto pliki ktore mam tutaj w tym katalogu:


LINEUPUPLOAD.JS
Link do kodu: Link do kodu

Functions.JS
Link do kodu: Link do kodu


Pierwszy bład wywala w lini 183 a w tej lini jest co to może znaczyć
Kod
function drawMessages(o) {
        if(!o){
        //alert(xmlhttp.status);
        }else{
        var bRes = true;
        var messageContainer = document.getElementById('messageContainer');
        messageContainer.innerHTML = '';
        messages = o.getElementsByTagName('message');
        for (var i = 0; i < messages.length; i ++) {
            sheet = document.createElement('div');
            sheet.id = 'sheet' + (new Date()).getTime();
            sheet.className = 'sheet-'+messages[i].getAttribute('cls');
            shtext = document.createElement('div');
            shtext.className = 'sheet-text';
            shtext.innerHTML = STR[messages[i].firstChild.nodeValue] ? STR[messages[i].firstChild.nodeValue] : messages[i].firstChild.nodeValue;
            sheet.appendChild(shtext);
            
            messageContainer.appendChild(sheet);
            setTimeout('var ob = document.getElementById("'+sheet.id+'"); if (ob) ob.style.display = "none"; if (getLineup && getLineup()) getLineup().drawAll();', 4000);
            
            if (messages[i].getAttribute('cls') == 'exception') {
                bRes = false;
            }
        }
        
        return bRes;
        }
    }





Za indywidualną pomoc jestem skłonny zapłacić za fatygę gdyż jest to dla mnie ważne smile.gif




Go to the top of the page
+Quote Post
Pyton_000
post 8.07.2017, 13:52:13
Post #2





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


To:
` messages = o.getElementsByTagName('message');`
raczej powinno być:

` messages = o.getElementsById('message');`
Go to the top of the page
+Quote Post
SethSeth
post 8.07.2017, 14:00:22
Post #3





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 8.07.2017

Ostrzeżenie: (0%)
-----


Próbowałem wcześniej nie działa ani jedno ani drugie..

W Firefoxie w debugerze mam takie coś:

Kod
TypeError: o is null[Więcej informacji]  lineupload.js:116:6
    onLineupsUpdate http://localhost/js/lineupload.js:116:6
    TConnection/this.oConn.onreadystatechange< http://localhost/js/Functions.js:86:6
    createMethodReference/<




Zauwazyłem ze w funkcji
`function drawMessages(o) {`
o jest null i nie wiem czemu

Ten post edytował SethSeth 8.07.2017, 14:03:09
Go to the top of the page
+Quote Post
Pyton_000
post 8.07.2017, 15:18:55
Post #4





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


to pokaż html
Go to the top of the page
+Quote Post
SethSeth
post 8.07.2017, 15:39:10
Post #5





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 8.07.2017

Ostrzeżenie: (0%)
-----


Oki doki
Ogólnie to jest skrypt ustalania składu do gry tylko ten element jest w js napisany przez kolege kiedyś no i chce go uzyć do gry tylko bladego pojęcia nie mam co to za null w zmiennej o i czymjest te o Mam wrazenie jak by to było 'var o = xmlhttp.responseXML;' i czym jest ten xml ?

Link do kodu


Na początku jest jeszcze require 'pliki/func/lineup.php';

a w nim jest to

Kod
<?php

define('GL_FUNC_LINEUP', 1);

function getLineupPlayers($sPlayers, $iIdKlub, $bWithReserve = false) {
    $aPlayers = unserialize(stripslashes($sPlayers));//print_r($aPlayers);
    $aPMod = array('B' => 'GK', 'O' => 'CB', 'P' => 'CM', 'N' => 'CF');
    //poczatki stref
    $aP = array('B' => array(0, 1), 'O' => array(2, 340), 'P' => array(341, 730), 'N' => array(731, 1000));
    $bGkSet = false;
    
    foreach ($aPlayers as $iKey => $aVal) {
        if ($aPlayerData = mysql_fetch_assoc(mysql_query('
            SELECT
                p.*
            FROM
                pilkarze AS p
            WHERE
                id = '.$aVal['id'].'
                AND (
                    id_klub = '.$iIdKlub.'
                    OR (
                        SELECT
                            COUNT(id)
                        FROM
                            powolania
                        WHERE
                            id_klub = '.$iIdKlub.'
                            AND id=p.id
                    ) =  1
                )
        '))) {
            $aPlayers[$iKey]['data'] = $aPlayerData;
            if ($aVal['reserve']) {
                $aPlayers[$iKey]['position'] = $aPMod[$aPlayerData['pozycja']];
                if (!$bWithReserve) {
                    unset($aPlayers[$iKey]);
                }
            } else {
                if (!$aPlayers[$iKey]['position'] or $aPlayers[$iKey]['position'] == 'undefined') {
                    foreach ($aP as $sPos => $aPosRange) {
                        if ($aVal['x'] >= $aPosRange[0] and $aVal['x'] <= $aPosRange[1]) {
                            $aPlayers[$iKey]['position'] = $aPMod[$sPos];
                        }
                    }
                }
                if ($aPlayers[$iKey]['position'] == 'GK') {
                    $bGkSet = true;
                    $aPlayers[$iKey]['x'] = 0;
                    $aPlayers[$iKey]['y'] = 250;
                }
            }
        } else {
            unset($aPlayers[$iKey]);
        }
    }
        
    if (!$bGkSet) {
        foreach ($aPlayers as $iKey => $aVal) {
            $aPlayers[$iKey]['position'] = 'GK';
            $aPlayers[$iKey]['x'] = 0;
            $aPlayers[$iKey]['y'] = 250;
            break;
        }
    }print_r($aPlayers);
    return print_r('xxxsadsaxx');
}

define('ZONE_GK', 0);
define('ZONE_DEF', 1);
define('ZONE_MID', 2);
define('ZONE_FED', 3);

function getZone($p, $bAsString)
{
    $aZones = array();
    $aZones['GK'] = ZONE_GK;
    $aZones['CB'] = ZONE_DEF;
    $aZones['LB'] = ZONE_DEF;
    $aZones['SB'] = ZONE_DEF;
    $aZones['RB'] = ZONE_DEF;
    $aZones['CM'] = ZONE_MID;
    $aZones['LM'] = ZONE_MID;
    $aZones['RM'] = ZONE_MID;
    $aZones['SM'] = ZONE_MID;
    $aZones['OM'] = ZONE_MID;
    $aZones['DM'] = ZONE_MID;
    $aZones['CF'] = ZONE_FED;
    if ($bAsString)
    {
        $aStrings = array('B', 'O', 'P', 'N');
        return $aStrings[$aZones[$p]];
    }
    else
        return $aZones[$p];
}

?>


Ten post edytował SethSeth 8.07.2017, 15:44:04
Go to the top of the page
+Quote Post
Pyton_000
post 8.07.2017, 18:19:19
Post #6





Grupa: Zarejestrowani
Postów: 8 068
Pomógł: 1414
Dołączył: 26.10.2005

Ostrzeżenie: (0%)
-----


Wydaje mi się że skrypt php się sypie, przez co zwrotka Ajax nie jest poprawna i wysypuje skrypt.

Dużo tam kodu, tu trzeba by usiąść nad całym skryptem i sprawdzać co nie działa.
Go to the top of the page
+Quote Post
SethSeth
post 21.07.2017, 21:57:02
Post #7





Grupa: Zarejestrowani
Postów: 17
Pomógł: 0
Dołączył: 8.07.2017

Ostrzeżenie: (0%)
-----


A może pomożesz prywatnie na PW zapłacęquestionmark.gif

Problem wkoncu rozwiązany racja błąd tkwił w ajaxie i przesyłaniu danych
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 19.04.2024 - 00:39