Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][AJAX] Logowanie
Axexis
post
Post #1





Grupa: Zarejestrowani
Postów: 98
Pomógł: 14
Dołączył: 13.01.2008
Skąd: Birmingham

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


y0! ;D

Zgłaszam się po kolejne rady (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)

A więc mam sobie formularz, który wysyłam via ajax.
W odpowiedzi dostaję np.
  1. <div id="blad">
  2. <h2>Blad</h2><h3>Zly login lub hasło</h3>
  3. </div>
  4.  
  5. <script type="text/javascript">
  6. function test()
  7. {
  8. alert('bu');
  9. }


I teraz.. Czy jest jakiś sposób, aby jakoś uruchomić funkcję test (z automatu)?

Czy jest w JS coś na wzór eval() z php? (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)

Ten post edytował Axexis 27.01.2009, 20:51:32
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Axexis
post
Post #2





Grupa: Zarejestrowani
Postów: 98
Pomógł: 14
Dołączył: 13.01.2008
Skąd: Birmingham

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


window.onload nie działa. Pisałem, że logowanie leci z ajaxu: Bez reloadu strony.
kod js dla zainteresowanych
Kod
function AJAXLogin()
{
    var url = "/zaloguj?do=login&ajax=1";
    var login = document.getElementById('login').value;
    var password = document.getElementById('pass').value;
    var divid = document.getElementById('form');
    var bladid = document.getElementById('blad');
    var parametry = "ulogin="+login+"&upassword="+password;
    if(login.length == 0 || password.length == 0)
    {
        bladid.innerHTML = '<h2>Bledne pole login/haslo!</h2><h3>Pole login lub haslo nie zostalo wypelnione! Prosimy sprobowac ponownie.</h3>';
        bladid.style.display='block';
    } else
    {
        bladid.style.display='none';
        ajaxobj.open("POST", url, true);
        ajaxobj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        ajaxobj.setRequestHeader("Content-length", parametry.length);
        ajaxobj.setRequestHeader("Connection", "close");
            
        ajaxobj.onreadystatechange = function()
        {
            if(ajaxobj.readyState == 1)
            {
                divid.innerHTML = '<center><h3>Logowanie....</h3></center>';
            } else if(ajaxobj.readyState == 4 && ajaxobj.status == 200)
            {
                divid.innerHTML = ajaxobj.responseText;
            }
        }
        ajaxobj.send(parametry);
    }
}
?>


Ten post edytował Axexis 27.01.2009, 20:57:55
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: 8.10.2025 - 10:47