Monday, July 09, 2007

Simple Ajax solution

We need to retrieve email address one by one through a MQ call for a report, (can you believe this?).

anyway, we don't want to hold our report for this, and there are still so many other informations besides email on the report. Therefore a Ajax solution is the best way to deal with this.

java script function:



   1:  function GetSLEmailByID(controlID, pol_nbr)

   2:  {

   3:        //alert(controlID);

   4:        //document.getElementById(controlID).innerText = "updating ...";

   5:        var xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");

   6:          xmlHttp.onreadystatechange=function()

   7:            {

   8:                if(xmlHttp.readyState==4)

   9:              {

  10:                  try

  11:                  {

  12:                      document.getElementById(controlID).innerHTML = xmlHttp.responseText;

  13:                  }

  14:                  catch(e)

  15:                  {

  16:                      alert(controlID+"\n"+e.message);

  17:                  }

  18:              }

  19:            }

  20:          xmlHttp.open("GET","slgetemail.aspx?pol=" + pol_nbr,true);

  21:          xmlHttp.send(null);

  22:  }