Calling Ajax Function in Struts Running Example

function AjaxFunction()
{
    var xmlHttp=GetXmlHttpObject();
    if (xmlHttp==null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    }
    var url="userwelcome.do?method=getContactById&contact_id="+cntId;
    xmlHttp.onreadystatechange=function()
    {
        if (xmlHttp.readyState==4)
        {
            var content=xmlHttp.responseText;
            document.getElementById("Res_Div_ID").innerHTML=    xmlHttp.responseText;
            document.getElementById("Div_ID").style.display        =    "none";
            document.getElementById("Disp_Div_ID").style.display=    "none";
        }
    };
    xmlHttp.open("POST",url,true);
    xmlHttp.send(null);
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try
    {
        // Firefox, Opera 8.0+, Safari
        xmlHttp=new XMLHttpRequest();
    }catch (e)
    {
        // Internet Explorer
        try
        {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
    }
    return xmlHttp;
}

Comments

Popular posts from this blog

php format date string short month

curl service example in php