客户端js
<script src="jquery-1.8.0.min.js"></script> <script src="JavaScript1.js"></script> <script src="jquery.cookie.js"></script> <script> $(function(){ jQuery.support.cors = true; if (!$.cookie('MyCookie')) { $.cookie('MyCookie', "userid%3D1111"); } //$.cookie('Zbb', "userid%3D123"); var MyCookie = decodeURIComponent($.cookie('MyCookie')); var UserID = MyCookie.substr(MyCookie.indexOf("=") + 1); onLogin("Get", 'http://11.11.152.225:8084/api/tbl_Task_Dispatch/GetDispatchList?userID='+UserID , zswFun); })
JavaScript1.js
//XmlHttpRequest对象 function createXmlHttpRequest(){ if(window.ActiveXObject){ //如果是IE浏览器 return new ActiveXObject("Microsoft.XMLHTTP"); }else if(window.XMLHttpRequest){ //非IE浏览器 return new XMLHttpRequest(); } } function onLogin(metched,url,zswFun){ //userName = document.f1.username.value; //passWord = document.f1.password.value; //url = "http://11.11.152.225:8084/api/tbl_Task_Dispatch/GetDispatchList?userID=90016"; //1.创建XMLHttpRequest组建 xmlHttpRequest = createXmlHttpRequest(); //2.设置回调函数 xmlHttpRequest.onreadystatechange = zswFun; //3.初始化XMLHttpRequest组建 xmlHttpRequest.open(metched,url,true); //4.发送请求 xmlHttpRequest.send(null); } //回调函数 function zswFun(){ if(xmlHttpRequest.readyState == 4 && xmlHttpRequest.status == 200){ var b = xmlHttpRequest.responseText; var data=$.parseJSON(b); $("#WaitHandlerCount").text(data.total); } }