dojo之ajax

前端之家收集整理的这篇文章主要介绍了dojo之ajax前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
< 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 >






原文链接:https://www.f2er.com/dojo/291967.html

猜你在找的Dojo相关文章