Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Complicated AJAX

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #25003
    AlCapone
    Participant

    Hi, I have sent from php and echo state ment – echo ‘done’ or echo ‘notdone’
    this is, in ajax code – taken in as xmlhttp.responseText. This is my code in ajax.

    Code:
    function stateChanged() {
    if (xmlhttp.readyState == 4 ) {
    responce = xmlhttp.responseText;
    if (responce == “done”) {
    document.getElementById(“box”).className = ‘done’;
    } else if (responce == “notdone”){
    document.getElementById(“box”).className = ‘notdone’;
    }
    }
    }

    Its, not working – the class is not changing on the box id.
    If, i put this,

    Code:
    function stateChanged() {
    if (xmlhttp.readyState == 4 ) {
    responce = xmlhttp.responseText;
    if (responce = “done”) {
    document.getElementById(“box”).className = ‘done’;
    }
    }
    }

    It works – notice how the first one, does not work at all. The second one has a single ‘=’ next to responce = done. But this does not work when i add the other section – probably because im forcing responce to change.

    Any Help?

    Many THanks

    #58390
    cssfreak
    Member

    Try this

    Code:
    function stateChanged() {
    if (xmlhttp.readyState == 4 )
    {
    if(xmlhttp.status==200)
    {
    responce = xmlhttp.responseText;
    if (responce == “done”) {
    document.getElementById(“box”).className = ‘done’;
    } else if (responce == “notdone”){
    document.getElementById(“box”).className = ‘notdone’;
    }
    }
    }
    }
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.