Hi all

Thanks for all your replies.
I tried to implement refreshing but as I am a beginner on javascript
and AJAX I was not successful.
I will appreciate if any of you have a look on my code and point what is wrong:



============================================================

<script type="text/javascript" language="JavaScript">
var xhr_refresh;
var READY_STATE_UNITIALIZED=0;
var READY_STATE_LOADING=1;
var READY_STATE_LOADED=2;
var READY_STATE_INTERACTIVE=3;
var READY_STATE_COMPLETE=4;
var HTTP_OK = 200;


function getXMLHttpRequest()
{
  var xhr = null;

  if (window.XMLHttpRequest) {
    // Mozilla/Safari
    xhr = new XMLHttpRequest();
  }else if ( typeof ActiveXObject != "undefined" ){
    // IE
    xhr = new ActiveXObject("MicroSoft.XMLHTTP");
  }
  return xhr;
}

function refresh()
{
    var portletId = "P-121f50c6235-10004";
    var page = "userHome.psml";
    var url = "http://localhost:8080/cranfieldPortal/portlet/"+page;
    event_refresh(url, portletId);
}

function doCounter(){
    setInterval("refresh()", 10000);
}

function event_refresh(url, portletId)
{
  xhr_refresh = getXMLHttpRequest();
  xhr_refresh.onreadystatechange = callback_refresh(portletId);
  xhr_refresh.open("GET", url, true);

  xhr_refresh.send( "entity="+portletId );

}

function callback_refresh(portletId)
{
  // Handle results if the ready state is complete
  if (xhr_refresh.readyState == READY_STATE_COMPLETE)
  {
    if (xhr_refresh.status == HTTP_OK){

     document.getElementById(portletId).innerHTML = xhr_refresh.responseXML;
    }

  }

}
</script>


### content of my jsp for portlet view mode ####

<script type="text/javascript">
  window.onload = function() {
      doCounter();
  };
</script>

============================================================


Is it correct if I do :

 document.getElementById(portletId).innerHTML = xhr_refresh.responseXML;

to replace portlet content ?


Thanks in advance for your help



Best Regards

Jan

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-user-unsubscr...@portals.apache.org
For additional commands, e-mail: jetspeed-user-h...@portals.apache.org

Reply via email to