dojo之ajax
发布时间:2020-12-16 21:54:59 所属栏目:百科 来源:网络整理
导读:label 输入您要投票的教师工号: inputtype = " text " name = " tId " id = " name " onmouSEOut = " helloPressed(); " / buttondojoType = " Button " widgetId = " helloButton " onClick = " helloPressed(); " 显示教师信息 / button / label js调用se
<
label
>
输入您要投票的教师工号:
<
inputtype
=
"
text
"
name
=
"
tId
"
id
=
"
name
"
onmouSEOut
=
"
helloPressed();
"
/>
< buttondojoType = " Button " widgetId = " helloButton " onClick = " helloPressed(); " > 显示教师信息 </ button > </ label > js调用server.jsp页面 显示回来..
<
scripttype
=
"
text/javascript
"
src
=
"
../dojojs/dojo.js
"
></
script
>
< scripttype = " text/javascript " > dojo.require( " dojo.widget.* " ); </ script > < script > function helloPressed() ... { dojo.io.bind(...{ url:'server.jsp', method:'POST', handler:helloCallback, content:...{name:dojo.byId('tId').value} }); } function helloCallback(type,data,evt) ... { if(type=='error') ...{ alert('读取服务器数据时出错'); } else ...{ dojo.byId("show").innerHTML=data; } } </ script > serve.jsp
<%
@pagecontentType
=
"
text/html;charset=GB2312
"
%>
<% @pageimport = " java.sql.*,com.teacher.*,com.pool.*; " %> <% request.setCharacterEncoding( " GB2312 " ); %> <%! Stringr1 = "" ,r2 = "" ,r3 = "" ,r4 = "" ,r5 = "" ,r6 = "" ,r7 = "" ; %> <% Stringname = null ,r7 = new String( "" ); name = request.getParameter( " name " ); if (name.length() != 0 &&! name.equals( "" )) ... { Connectionconn=null; Statementstmt=null; ResultSetrs=null; Stringsql="select*fromteacherwheretId="+name+";"; try...{ conn=ConnDB.getConnection(); stmt=conn.createStatement(); rs=stmt.executeQuery(sql); if(rs.next()) ...{ r1=rs.getString(1); r2=rs.getString(2); r3=rs.getString(3); r4=rs.getString(4); r5=rs.getString(5); r6=rs.getString(6); }else ...{ r7="没有这个老师!请查询清楚!"; } }catch(Exceptionex) ...{ ex.printStackTrace(); } } if (r7.length() == 0 && r7.equals( "" )) ... { %><table><tr><td><%=r1%></td><td><%=r2%></td><td><%=r3%></td><td><%=r4%></td><td><%=r5%></td><td><%=r6%></td></tr></table> <table> <%} else ... { %> <tr><td><%=r7%></td></tr> <%} %> </ table > (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |