function writeFile(path,data){ var fso, f, s ; fso = new ActiveXObject("Scripting.FileSystemObject"); if(isFile(path)){ fso.DeleteFile(path); } f = fso.OpenTextFile(path,8,true); f.WriteLine(data); f.Close(); } function isFile(path){ var fso = new ActiveXObject("Scripting.FileSystemObject"); var f = fso.FileExists(path); return f; } function synchronyInfo(){ var httpRequest = new HttpRequest("../offRegionPolice/synchronyInfo.action", "post", { onRequestSuccess : function(responseText) { if("error" == responseText){ alert("同步出错,请重试"); }else{ var tmsTaskAppInfoJsons=responseText.split("=="); writeFile("D:\\autoData.json",tmsTaskAppInfoJsons[0]); writeFile("D:\\data.json",tmsTaskAppInfoJsons[1]); alert("同步成功!"); } } }); httpRequest.sendRequest(false); } //同步销单信息 function synchronyFinishInfo(){ var data=readFile("D:\\finishData.json") var httpRequest = new HttpRequest("../offRegionPolice/synchronyFinishInfo.action", "post", { onRequestSuccess : function(responseText) { if("" == responseText){ alert("上传数据成功!"); search_list_page(); }else{ alert(responseText); } } }); httpRequest.addParameter("parameter['finishData']",data); httpRequest.sendRequest(false); } function readFile(path) { var data = new Array(); var fso = new ActiveXObject("Scripting.FileSystemObject"); var f = fso.OpenTextFile(path, 1); while (!f.AtEndOfStream) { var line = f.ReadLine(); data.push(line.split("\t")); } f.Close(); return data; }