1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| <html>
<head>
<script src="js/prototype.js" type="text/javascript"></script>
<script src="js/rico.js" type="text/javascript"></script>
<script language="javascript">
ajaxEngine.registerRequest("getElement", "returnElement.jsp");
ajaxEngine.registerRequest("getObject", "returnObject.jsp");
function runMe1() {
ajaxEngine.registerAjaxElement("helloId");
ajaxEngine.registerAjaxElement("sayHello");
ajaxEngine.registerAjaxElement("fromElementId",$("toElementId"));
var pramas = "Name="+document.getElementById("userName").value;
ajaxEngine.sendRequest("getElement",pramas);
}
ajaxEngine.registerAjaxObject("objectId",new UserObject());
function runMe2(){
ajaxEngine.sendRequest("getObject",
"rName="+document.getElementById("uName").value,
"rAge="+document.getElementById("age").value);
}
function UserObject(){
this.ajaxUpdate=function(ajaxResponse){
var objs = ajaxResponse.getElementsByTagName('returnObject');
var tabStr="<table border='1'><tr><td>姓名</td><td>年齡</td></tr>"for(var i=0;i<objs.length;i++){
tabStr+="<tr><td>";
tabStr+=objs[i].getAttribute("name")+"</td><td>"+objs[i].getAttribute("age");
tabStr+="</td></tr>";
}
tabStr+="</table>";
this.setValue(tabStr);
}
this.setValue=function(str){
document.getElementById("result").innerHTML=str;
}}
</script>
</head>
<body>
<h3>Element Test</h3>
Your Name:<input type="text" id="userName" name="userName">
<input type="button" name="BT" value="click me" onclick="runMe1()">
<table><tr><td><div id="helloId"></div></td><td><div id="toElementId"></div></td></tr></table>
<div id="sayHello"></div>
<hr>
<h3>Object Test</h3>
Your Name:<input type="text" id="uName" name="uName">
Your Age:<input type="text" id="age" name="age">
<input type="button" value="Click Me" onclick="runMe2()">
<div id="result"></div>
</body>
</html>
|