﻿function Call(url,operation,body,resultfun)
{
    // Create HTTP request
    var xmlHttp;
    try 
    {
        xmlHttp = new XMLHttpRequest();
    } 
    catch (e) 
    {
        try 
        {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        } 
        catch (e) 
        {
            try 
            {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (e) 
            {
                alert("This sample only works in browsers with AJAX support"); 
                return false;
            }
        }
    }

    // Create result handler 
    xmlHttp.onreadystatechange=function()
    {
        if(xmlHttp.readyState == 4)
        {
        	
            //获取对象
        	var oJSON = JSON.decode(xmlHttp.responseText);
        	var oResult = oJSON.d;
            resultfun.call(this,oResult);
        }
    }

    try
    {
        url = url + operation;
        
        // Send the HTTP request
        xmlHttp.open("POST", url, true);
        xmlHttp.setRequestHeader("Content-type", "application/json");
        
         if (body=="" || body==null)
            xmlHttp.send();
        else
            xmlHttp.send(body);

    }
    catch(e)
    {
        alert(e);
    }

}

