AJAX problem

Discussion in 'JavaScript' started by Agent_Dweeb, Dec 7, 2007.

  1. #1
    
    dnscrub.com
    
    Code (markup):
    Go to there and right now it says in a pop up window

    'There was a problem with the request'

    Here is the piece of code regarding this
    
     function alertContents() {
          if (http_request.readyState == 4) {
             if (http_request.status == 200) {
                //alert(http_request.responseText);
                result = http_request.responseText;
                document.getElementById('myspan').innerHTML = result;            
             } else {
                alert('There was a problem with the request.');
             }
          }
       }
    
    Code (markup):
    Can anyone explain to me what it means?
    and how to fix the problem and for the whole site to work again

    Thanks a lot and rep will be given!
     
    Agent_Dweeb, Dec 7, 2007 IP
  2. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
  3. hrcerqueira

    hrcerqueira Peon

    Messages:
    125
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #3
    It means that the status of the request was no 200 (the success status), and any other one like the famous 400 (server error), 500 (client error, usually troubles in connection), 404 (page not found), etc. It would be useful to know the error code, it would help you a lot. Replace alert('There was a problem with the request.'); by alert(http_request.status);, then report back the result here.

    Hope it helps...
     
    hrcerqueira, Dec 7, 2007 IP
  4. Agent_Dweeb

    Agent_Dweeb Peon

    Messages:
    5,607
    Likes Received:
    384
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Let me change that just for you then :)
     
    Agent_Dweeb, Dec 8, 2007 IP