Ajax Response

Discussion in 'JavaScript' started by bglive, Aug 8, 2008.

  1. #1
    I have the following code (part of it):

    
    ajax.onCompletion = createList;
    ajax.runAJAX();
    
    function createList()
    {
    	var obj = document.getElementById('myList');
    	eval(ajax.response);
    }
    
    Code (markup):
    I am trying to only display the second drop down only if there were actual options returned from the PHP file. I can not figure out what to test for to see if there was no response or not from the request.

    It looks like even if I pass nothing from the php file, that the ajax.response returns something. I have not done JS in a while, so any help is much appreciated.
     
    bglive, Aug 8, 2008 IP
  2. koolman

    koolman Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    As I understand from your code, the ajax.response must be a javascript code string.
    Please let me know the ajax.response content in 2 cases:
    1 . When there is option sent from server
    2. When there is no option sent from server
     
    koolman, Aug 8, 2008 IP
  3. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #3
    if (ajax.responseText)
    Code (markup):
    ?
     
    MMJ, Aug 9, 2008 IP