简洁实用的ajax封装

简洁实用的ajax封装
简洁实用的ajax封装 
ajaxjavascript .
/**
ajax封装
*/
ygsoft_test_script_helper.ajax=function(method,url,data,func)
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function ()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
    //返回后处理
    func(xmlhttp.responseText);
         }
         }
xmlhttp.open(method, url, true);
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(data);
}

你可能感兴趣的:(简洁实用的ajax封装)