I am trying to get response from ASP page(inside which I'm creating dynamic javascript array). But after AJAX callback, I'm not able to access the javascript array.
I have gone through stackoverflow article Calling a JavaScript function returned from an Ajax response which addresses issues similar to mine.
Not sure what is wrong in this. I'm giving below brief idea of the code I've written.
Function ()
{
  var xmlhttp;
  if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
  } else { // code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  }
  xmlhttp.onreadystatechange = function () {
    if (xmlhttp.readyState == 1) {
      alert('connection');
    }
    if (xmlhttp.readyState == 3) {
      alert('processing');
    }
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      alert('back with the bang');
      document.getElementById('dvCallback').innerHTML = xmlhttp.responseText;
      eval(document.getElementsByID("runscript").innerHTML);
      split1 = arrJSCalT[i].split(":");
      alert(split1[1]);
    }
  }
  xmlhttp.open("POST", "Sys_Add.asp", true);
  xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlhttp.send();
  return false;
}
Sys_Add.asp is as below.
 <%
    response.Expires = -1
    dim strErrMsg
    recCntr = 0
    recCntr = rsCalT.RecordCount
    recCntr = recCntr - 1
    dim dicCalT
    set dicCalT = CreateObject("Scripting.Dictionary")
    if rsCalT.RecordCount <> 0 then
    rsCalT.MoveFirst
    do while not rsCalT.EOF
    dicCalT.Add cstr(rsCalT(0)), cstr(rsCalT(1))
    rsCalT.MoveNext
    loop
    end if
    Call FillJSArray(dicCalT,"arrJSCalT")
    Sub FillJSArray(dicVB, arrJS)
        dim itr
        a = dicVB.keys
        b = dicVB.items
        Response.write ("<script language=""javascript"" id=""runscript"" name =""runscript"">" & VbCrLf )
        Response.Write ("var " & arrJS & "= new Array(" )
        for i = 0 To dicVB.Count - 1
            If i > 0 then
                response.write (",")
            End If
            Response.Write ("""" & a(i) & ":" & b(i) & """")
        Next
        Response.Write (");" & vbCrLf )
        'Response.write "alert(""running from main"");"
        Response.write ("</script>" & VbCrLf)
        Response.write ("so this is printed as welll")
    End Sub
    'END creating javascript array from asp recordset
  response.Write ("Did you want this??")
%>
I get error at line split1 = arrJSCalT[i].split(":"); I would appreciate if I get assistance on this.
Thanks... Prashant....
 
     
     
    