WorkSpace Communication with JIA

A WorkSpace extension will call exposed methods using JavaScript Ajax calls. For example:

function xmlhttpPost(strURL, id) {

    var xmlHttpReq = false;

    var self = this;

    // Mozilla/Safari

    if (window.XMLHttpRequest) {

      self.xmlHttpReq = new XMLHttpRequest();

    }

    // IE

    else if (window.ActiveXObject) {

      self.xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");

    }

    self.xmlHttpReq.open('POST', strURL, true);

    self.xmlHttpReq.setRequestHeader('Content-Type', 'application/json');

    self.xmlHttpReq.onreadystatechange = function() {

      if (self.xmlHttpReq.readyState == 4) { //ready state 4 means its complete.

        updatepage(self.xmlHttpReq.responseText);

      }

    }

    self.xmlHttpReq.send(getquerystring(id));

}

 

function getquerystring() {

          var body = '{"url":"' + content.document.URL + '"}';

    return body;

}

 

function run(event)

{

          if (event.originalTarget instanceof HTMLDocument)

          {

                xmlhttpPost("http://localhost:9005/Services/Service/OnLoad");

          }

}