Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [js] problem z klasa, pierwszy obiekt w zyciu w js
Balon
post
Post #1





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


Kod
function Auth()
{
    var url = 'lib/ajax_request.php';
    var params = 'action=login&login=' + $F( 'form_login' ) + '&pass=' + $F( 'form_pass' );
    
    function login()
    {
        var ajax = new Ajax.Request( this.url, { parameters: this.params, onLoading: msgBox( 'SHOW', 'Loading...' ), onSuccess: msgBox( 'Logged...' ), onFauilure: reportError} );
        switch( ajax.responseText )
        {
            case 'OK': this.msgBox( 'SHOW', 'Logged ...' ); this.pause( 1000 ); this.msgBox( 'HIDE', '' ); break
                
        }
    }
    
    function msgBox( type, msg )
    {
        $F( 'msg_box' ).innerHTML = msg;
        switch( type )
        {
            case 'HIDE': $F( 'msg_box' ).style.display = 'none'; break
            case 'SHOW': $F( 'msg_box' ).style.display = 'block'; break
        }
    }
    
    function pause( ms )
    {
        var now = new Date();
        var exitTime = now.getTime() + ms;
    
        while( true )
        {
            now = new Date();
            if( now.getTime() > exitTime ) return;
        }
    }
}


a wywoluje to tak

  1. <form action="login/" method="post" onsubmit="var auth = new Auth(); auth.login(); return false;">


wywala i przekierowuje mnie na login/ i blad bo to tylko dla picu jest to login/ bo ma wykonywac ten formularz ajax
Cytat
Błąd: Auth is not defined
Plik źródłowy: http://127.0.0.1/~book/
Wiersz: 1


co robie zle ?

wiem ze jestem zielony ale jakos trza zaczynac (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Balon
post
Post #2





Grupa: Zarejestrowani
Postów: 422
Pomógł: 0
Dołączył: 14.12.2005
Skąd: Wałbrzych

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


Kod
/**
* This file is part of G-system.
* @copyright 2006 All rights reserved, do not copy, edit or resale.
* @author Krzysztof Jagiełło <balonyo@gmail.com>
* @version 0.1
*/

function Auth()
{
    this.url = 'lib/ajax_request.php';
    this.params = 'action=login&login=' + $F( 'form_login' ) + '&pass=' + $F( 'form_pass' );
    
    this.login = function login()
    {
        var ajax = new Ajax.Request( this.url, { parameters: this.params, onLoading: msgBox( 'SHOW', 'Loading...' ), onSuccess: msgBox( 'Logged...' ), onFauilure: reportError} );
        switch( ajax.responseText )
        {
            case 'OK': this.msgBox( 'SHOW', 'Logged ...' ); this.pause( 1000 ); this.msgBox( 'HIDE', '' ); break
            case 'ERROR': this.msgBox( 'SHOW', 'Error ...' ); this.pause( 1000 ); this.msgBox( 'HIDE', '' ); break
        }
    }
    
    this.msgBox = function msgBox( type, msg )
    {
        $F( 'msg_box' ).innerHTML = msg;
        switch( type )
        {
            case 'HIDE': $F( 'msg_box' ).style.display = 'none'; break
            case 'SHOW': $F( 'msg_box' ).style.display = 'block'; break
        }
    }
    
    this.pause = function pause( ms )
    {
        var now = new Date();
        var exitTime = now.getTime() + ms;
    
        while( true )
        {
            now = new Date();
            if( now.getTime() > exitTime ) return;
        }
    }
}

var auth = new Auth;


nadal nie dziala....


jak mozesz to przetestuj bo nie wiem co jest grane (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 5.10.2025 - 02:53