From c242bf6bb1440760c6eef7c22d16c54e773408ac Mon Sep 17 00:00:00 2001 From: istars Date: Sun, 13 Jan 2019 17:35:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/src/main/resources/static/allOrders.html | 4 +- demo/src/main/resources/static/js/myorder.js | 98 +++++++++++++++++++ demo/src/main/resources/static/js/order.js | 58 ----------- .../main/resources/static/js/productshow.js | 84 ++++++++++++++++ demo/src/main/resources/static/js/show.js | 58 ----------- .../main/resources/static/productshow.html | 2 +- 6 files changed, 186 insertions(+), 118 deletions(-) create mode 100644 demo/src/main/resources/static/js/myorder.js delete mode 100644 demo/src/main/resources/static/js/order.js create mode 100644 demo/src/main/resources/static/js/productshow.js delete mode 100644 demo/src/main/resources/static/js/show.js diff --git a/demo/src/main/resources/static/allOrders.html b/demo/src/main/resources/static/allOrders.html index 9d74555..d14d2a4 100644 --- a/demo/src/main/resources/static/allOrders.html +++ b/demo/src/main/resources/static/allOrders.html @@ -10,6 +10,8 @@ + + @@ -28,7 +30,7 @@ -
+
diff --git a/demo/src/main/resources/static/js/myorder.js b/demo/src/main/resources/static/js/myorder.js new file mode 100644 index 0000000..c93e540 --- /dev/null +++ b/demo/src/main/resources/static/js/myorder.js @@ -0,0 +1,98 @@ +window.onload(function requestData(){ + $.ajax({ + url: "/search", + type: "post", + dataType: "json", + success: function(data){ + /*这个方法里是ajax发送请求成功之后执行的代码*/ + showData(data);//我们仅做数据展示 + }, + error: function(msg){ + alert("ajax连接异常:"+msg); + } + }); +}); + +//展示数据 +function showData(data) { + var str = "";//定义用于拼接的字符串 + $("#orderlist").html=null; + for (var i = 0; i < data.length; i++) { + var audit = data[i]; + var str = "\n" + + "
\n" + + "
audit.applyTime
\n" + + "
\n" + + "
\n" + + "

audit.checkNum

\n" + + " \n" + + "
\n" + + "
\n" + + "
\n" + + " \n" + + "
\n" + + "
\n" + + "
\n" + + "
"; + $("#orderlist").append(str); + } + +} +// var xmlHttp = null;//声明XMLHttpRequest +// +// // 创建XMLHttpRequest对象 +// function createXMLHttpRequest() { +// // 已创建XMLHttpRequest对象,直接返回 +// if (xmlHttp != null) +// return; +// // 检测浏览器针对(FireFox、Chrome、Safari、Opera与IE7+)是否支持直接创建XMLHttpRequest +// if (window.XMLHttpRequest) { +// xmlHttp = new XMLHttpRequest(); +// // 检测否是IE浏览器 +// } else if (window.ActiveXObject) { +// try { +// // IE6 +// xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); +// } catch (e) { +// // IE5 +// xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); +// } +// } +// } +// +// +// //发送请求 +// function sendRequest(){ +// // 创建异步发送请求对象 +// createXMLHttpRequest(); +// //非0、非null、true表示真 +// if (!xmlHttp){ +// alert("XMLHttpRequest对象创建失败!!"); +// return; +// } +// var str = document.getElementById("txtMessage").value; +// +// /*GET方式发送请求 +// //初始化请求 +// xmlHttp.open("GET","AjaxMessageServlet?message="+str,true); +// //设置回调函数 +// xmlHttp.onreadystatechange=showMessage; +// xmlHttp.send(null);*/ +// +// //Post方式发送请求 +// xmlHttp.open("POST","AjaxMessageServlet",true); +// xmlHttp.onreadystatechange=showMessage; +// xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//设置编码方式 +// xmlHttp.send("message="+str); +// } +// +// +// //回调函数 +// function showMessage(){ +// //判断就绪状态和响应状态码是否符合要求 +// if(xmlHttp.readyState==4&&xmlHttp.status==200) { +// var result = xmlHttp.responseText;//接收服务器响应的文本 +// document.getElementById("myspan").innerHTL = result; +// } +// } + diff --git a/demo/src/main/resources/static/js/order.js b/demo/src/main/resources/static/js/order.js deleted file mode 100644 index f25a897..0000000 --- a/demo/src/main/resources/static/js/order.js +++ /dev/null @@ -1,58 +0,0 @@ -var xmlHttp = null;//声明XMLHttpRequest - -// 创建XMLHttpRequest对象 -function createXMLHttpRequest() { - // 已创建XMLHttpRequest对象,直接返回 - if (xmlHttp != null) - return; - // 检测浏览器针对(FireFox、Chrome、Safari、Opera与IE7+)是否支持直接创建XMLHttpRequest - if (window.XMLHttpRequest) { - xmlHttp = new XMLHttpRequest(); - // 检测否是IE浏览器 - } else if (window.ActiveXObject) { - try { - // IE6 - xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - // IE5 - xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); - } - } -} - - -//发送请求 -function sendRequest(){ - // 创建异步发送请求对象 - createXMLHttpRequest(); - //非0、非null、true表示真 - if (!xmlHttp){ - alert("XMLHttpRequest对象创建失败!!"); - return; - } - var str = document.getElementById("txtMessage").value; - - /*GET方式发送请求 - //初始化请求 - xmlHttp.open("GET","AjaxMessageServlet?message="+str,true); - //设置回调函数 - xmlHttp.onreadystatechange=showMessage; - xmlHttp.send(null);*/ - - //Post方式发送请求 - xmlHttp.open("POST","AjaxMessageServlet",true); - xmlHttp.onreadystatechange=showMessage; - xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//设置编码方式 - xmlHttp.send("message="+str); -} - - -//回调函数 -function showMessage(){ - //判断就绪状态和响应状态码是否符合要求 - if(xmlHttp.readyState==4&&xmlHttp.status==200) { - var result = xmlHttp.responseText;//接收服务器响应的文本 - document.getElementById("myspan").innerHTL = result; - } -} - diff --git a/demo/src/main/resources/static/js/productshow.js b/demo/src/main/resources/static/js/productshow.js new file mode 100644 index 0000000..491b244 --- /dev/null +++ b/demo/src/main/resources/static/js/productshow.js @@ -0,0 +1,84 @@ +window.onload(function requestData(){ + $.ajax({ + url: "/search", + type: "post", + dataType: "json", + success: function(data){ + /*这个方法里是ajax发送请求成功之后执行的代码*/ + showData(data);//我们仅做数据展示 + }, + error: function(msg){ + alert("ajax连接异常:"+msg); + } + }); +}); + +//展示数据 +function showData(data) { + var str = "";//定义用于拼接的字符串 + $("#content").html=null; + for (var i = 0; i < data.length; i++) { + var pro = data[i]; + var str = '
'+pro.productName+'

'+pro.productNum+'

'; + $("#content").append(str); + } + +} +// var xmlHttp = null;//声明XMLHttpRequest +// +// // 创建XMLHttpRequest对象 +// function createXMLHttpRequest() { +// // 已创建XMLHttpRequest对象,直接返回 +// if (xmlHttp != null) +// return; +// // 检测浏览器针对(FireFox、Chrome、Safari、Opera与IE7+)是否支持直接创建XMLHttpRequest +// if (window.XMLHttpRequest) { +// xmlHttp = new XMLHttpRequest(); +// // 检测否是IE浏览器 +// } else if (window.ActiveXObject) { +// try { +// // IE6 +// xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); +// } catch (e) { +// // IE5 +// xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); +// } +// } +// } +// +// +// //发送请求 +// function sendRequest(){ +// // 创建异步发送请求对象 +// createXMLHttpRequest(); +// //非0、非null、true表示真 +// if (!xmlHttp){ +// alert("XMLHttpRequest对象创建失败!!"); +// return; +// } +// +// //Post方式发送请求 +// xmlHttp.open("POST","SearchServiceController",true); +// xmlHttp.onreadystatechange=showProduct; +// xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//设置编码方式 +// xmlHttp.send("message="+str); +// } +// +// +// //回调函数 +// function showProduct(){ +// //判断就绪状态和响应状态码是否符合要求 +// if(xmlHttp.readyState==4&&xmlHttp.status==200) { +// var jsonPro = xmlHttp.responseText;//接收服务器响应的文本 +// $("#content").html=null; +// for(var i=0;i

'+pro.productNum+'

'; +// $("#content").append(str); +// } +// +// +// } +// } +// +// diff --git a/demo/src/main/resources/static/js/show.js b/demo/src/main/resources/static/js/show.js deleted file mode 100644 index 5b9a604..0000000 --- a/demo/src/main/resources/static/js/show.js +++ /dev/null @@ -1,58 +0,0 @@ -var xmlHttp = null;//声明XMLHttpRequest - -// 创建XMLHttpRequest对象 -function createXMLHttpRequest() { - // 已创建XMLHttpRequest对象,直接返回 - if (xmlHttp != null) - return; - // 检测浏览器针对(FireFox、Chrome、Safari、Opera与IE7+)是否支持直接创建XMLHttpRequest - if (window.XMLHttpRequest) { - xmlHttp = new XMLHttpRequest(); - // 检测否是IE浏览器 - } else if (window.ActiveXObject) { - try { - // IE6 - xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); - } catch (e) { - // IE5 - xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); - } - } -} - - -//发送请求 -function sendRequest(){ - // 创建异步发送请求对象 - createXMLHttpRequest(); - //非0、非null、true表示真 - if (!xmlHttp){ - alert("XMLHttpRequest对象创建失败!!"); - return; - } - - //Post方式发送请求 - xmlHttp.open("POST","SearchServiceController",true); - xmlHttp.onreadystatechange=showProduct; - xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//设置编码方式 - xmlHttp.send("message="+str); -} - - -//回调函数 -function showProduct(){ - //判断就绪状态和响应状态码是否符合要求 - if(xmlHttp.readyState==4&&xmlHttp.status==200) { - var jsonPro = xmlHttp.responseText;//接收服务器响应的文本 - $("#content").html=null; - for(var i=0;i

'+pro.productNum+'

'; - - } - $("#content").append(str); - - } -} - - diff --git a/demo/src/main/resources/static/productshow.html b/demo/src/main/resources/static/productshow.html index 2a00583..2cadaeb 100644 --- a/demo/src/main/resources/static/productshow.html +++ b/demo/src/main/resources/static/productshow.html @@ -9,7 +9,7 @@ - +