views:

30

answers:

1

Hi :) When using Firebug i can see it returns 0 or 1, so the php is ok. But seems like ajax server_reponse isnt getting it.. somehow. Anyone see the problem?

j.ajax({
    type: "POST",
    url: "php/inc/ajax_check_username.php",
    data: "username=" + username,
    success: function (server_response) {

        j("#availability_status").ajaxComplete(function (event, request) {
            if (server_response == '0') {
                alert('ledig..');
                j("#availability_status").html('<p>Ok 0</p> <font color="Green"> Ledig! </font>');
            } else if (server_response == '1') {
                alert('IKKE ledig..');
                j("#availability_status").html('<p>Ok 1</p> <font color="red">Ikke Ledig... </font>');
            }

        });
    } // server resp
});
A: 

have you tried just this

j.ajax({
    type: "POST",
    url: "php/inc/ajax_check_username.php",
    data: "username=" + username,
    success: function (server_response) {   

            if (server_response == '0') {
                alert('ledig..');
                j("#availability_status").html('<p>Ok 0</p> <font color="Green"> Ledig! </font>');
            } else if (server_response == '1') {
                alert('IKKE ledig..');
                j("#availability_status").html('<p>Ok 1</p> <font color="red">Ikke Ledig... </font>');
            }    

    } // server resp
});

and what are the possible response from server? just '0' or '1'?

Reigel
Thanx for the edit, couldnt get the code thingy to work :/.Tried removing .ajaxComplete.. now but same thing, nothing :p Seems like it stops at the If, have an alert just before it and that fires.
Thundercat
based on my answer above, try `alert(server_response)` before `if (server_response == '0') {...` let see if we got something...
Reigel
woh.. it reponded correct! 0 and 1 with hit. Ok.. removed the '' around 0 and 1 ,and now it works 100% :)) Guess its because its data, not text.. or?
Thundercat
so no problem now?... You may accept this answer... just click the check button... ;)
Reigel
Works fine with server_response == 0 NOT server_response == '0' :DThanks very much!! :)
Thundercat