Hi,

I got a question: Is it possible to pass the responseText from an ajax call?
If not can i call another function from within a function that made an ajax call?


Here is the jist of it. In the second function, fill_tr_details, i get a responseText, of which contains the input values. There is a modal window, which contains a form. I extract some of the data from the responseText and set the values of the inputs accordingly. Then i need to use the rest of the values from the responseText to extract the appropriate sets of values for a dropdown list (and display the selected value). pull_childlist does this perfectly, but now that i am calling from within another ajax call its not working. Can someone explain to me the reasoning behind this?

Code:
ffunction pull_childlist(val, flag, sel)
{
  if(flag)
  {
    if(val == "pj")
    {
      var stagelist = "<br>\n<label class=\"modal_label\">Stages:</label>\n";
      stagelist += "<select id = \"stagelist\" name=\"stagelist\" disabled=\"disabled\">\n";
      stagelist += "<option>None</option>\n";
      stagelist += "</select>\n";
      document.getElementById("stagelistcont").innerHTML = stagelist;
    }
    else if(document.getElementById("stagelist"))
    {
      document.getElementById("stagelistcont").innerHTML = "";
    }
  }

  var myscript = "work_activities.php";
  var params = flag ? "subset="+val : "subset="+val+"|stage";
  params += (sel != -1) ? "&sel="+sel : "";
  http.open("POST", myscript, true);

  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  http.onreadystatechange = function(){
    if(http.readyState == 4 && http.status == 200)
    {
      if(flag)
      {
        var childlist = document.getElementById("childlist");
        childlist.removeAttribute("disabled");
        childlist.innerHTML = http.responseText;
      }
      else
      {
        var stagelist = document.getElementById("stagelist");
        stagelist.removeAttribute("disabled");
        stagelist.innerHTML = http.responseText;
      }
  	}
  }
  http.send(params);
}

function fill_tr_details(tr_id)
{
  var myscript = "tr_details.php";
  var params = "tr="+tr_id;
  http.open("POST", myscript, true);

  http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http.setRequestHeader("Content-length", params.length);
  http.setRequestHeader("Connection", "close");

  http.onreadystatechange = function(){
    if(http.readyState == 4 && http.status == 200)
    {
      var info = (http.responseText).split("|");

      document.getElementById("start_time").value = info[0];
      document.getElementById("end_time").value = info[1];
      document.getElementById("sel_date").value = info[2];
      document.getElementById("comments").value = info[3];

      var wid = info[4];

      if(info[5] == "stage")
      {
        pull_childlist("pj", true, info[6]);
        pull_childlist(info[6], false, wid);
      }
      else
      {
        pull_childlist(info[5], true, wid);
      }     

  	}
  }
  http.send(params);
}
Cheers!