The article provides a simple ASP tutorial Ajax example (post,get,form test) Oh, he did three related Ajax ASP test examples, all passed.
<!doctype HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.111cn.net/tr/xhtml1/dtd/ Xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> al-Ain Ajax class </title>
<link type= "text/css Tutorial" rel= "stylesheet" href= "Css.css"/>
<script language= "Web Effects" type= "Text/javascript" src= "Jo.ajax.js" ></script>
<script language= "javascript" type= "Text/javascript" >
/* Test AJAX features (like jquery Ajax, features not powerful, but more convenient to use), automatically prevent caching * *
function Testajax () {
document.getElementById ("Ajaxresult"). Innerhtml= " Request data ...";
Ajax ({
Asc:true,
URL: "test_ajax.asp?get=" + "my id is Anlige". UTF8 (),
Data: "Post=tandy",
Method: "Post",
DataType: "JSON",
Succeed:function (msg,obj,setting) {
var str= "";
str=str+ "Requested URL:" + setting.url + "<br/>";
Str=str+ "The Way of the request:" + Setting.method + "<br/>";
str=str+ "Requested data:" + Setting.data + "<br/><br/>";
str=str+ "returned text:" + obj.responsetext + "<br/><br/>";
str+= "JSON data: <br/>";
str+= "My id is:" + msg.id + "<br/>";
str+= "My name is:" + msg.name + "<br/>";
document.getElementById ("Ajaxresult"). Innerhtml=str;
}
});
return true;
}
Function ServerVariables (variable) {
document.getElementById ("Variresult"). Innerhtml= " variable reads ...";
Ajax ({
URL: "test_ajax_time.asp",
method: ' Get ',
datatype: ' Text ' ,
data: "v=" + variable,
Succeed:function (msg) {
document.getElementById ("Variresult"). Innerhtml=variable + "=" + msg;
}
});
}
function Postfrom (obj) {
Ajax ({
Form:obj,
DataType: "Text",
Succeed:function (msg,o,s) {
document.getElementById ("Formajaxresult"). Innerhtml=msg;
},
Error:function (s) {alert (s);}
});
}
function Testget () {
Ajax.get ("test_ajax_time.asp", "V=url", Function (msg) {alert (msg);});
}
function Testpost () {
Ajax.post ("test_ajax.asp", "Post=tandy", Function (msg) {alert (msg);});
}
</script>
<body>
<p><span style= "font-size:12pt" ><strong> Al Ain Ajax class </strong></span></p>
Get server variable: <input type= "text" id= "Vari" size= "value=" REMOTE_ADDR "onblur=" return ServerVariables (This.value); "/& Gt The text box loses focus and automatically invokes <br/>
<div id= "Variresult" ></div>
<div class= "Info" > you can enter other related variables for testing, such as http_referer,url,server_name</div><br/>
<input type= "button" value= "Get JSON data" onclick= "return Testajax ();" style= "font-size:9pt"/> "
<div id= "Ajaxresult" style= "font-size:9pt" ></div>
<form action= "Test_post_form.asp?myname=anlige" method= "POST" >
Text box: <span><input type= "text" name= "Text1" value= "test" style= "border:1px #ddd solid;"/></span> <br/>
check box 1:<input type= "checkbox" Name= "Check1" value= "" style= "border:0px"/><br/>
check box 2:<input type= "checkbox" Name= "Check2" value= "The value of Check2" style= "border:0px"/><br
Radio Box: <input type= "Radio" name= "Radio" value= "value1" style= "border:0px"/> option 1 <input type= "Radio" name= "Radio" Value= "value2" style= "border:0px"/> Option 2<br
Drop-down list: <select name= "Select1" >
<option value= "test1" > Test 1</option>
<option value= "test2" > Test 2</option>
</select>
<input type= "Submit" value= "submitted" onclick= "Postfrom (this.form);"/>
</form>
<div id= "Formajaxresult" style= "font-size:9pt" ></div>
<input type= "button" value= "Test Ajax.get" onclick= "Testget ();"/>
<input type= "button" value= "Test Ajax.post" onclick= "Testpost ();"/>
<!--
Ajax Class Library Usage instructions
-->
<p>
<span>
Full call to the unified call Portal: <span style= "color: #ff0000" >ajax (setting);</span> about parameter setting, please refer to the instructions below. <br/><br/>
Simple call Entry: <span style= "color: #ff0000" >ajax.get (URL,DATA,FN);</span> and <span style= "color: #ff0000" > Ajax.post (URL,DATA,FN); </span><br/><br/>
Ajax configuration: <br/>
<span style= "color: #0000ff" >
var</span> settings = {
<br/>
<span style= "color: #ff0000" > Asc</span>: <span style= "color: #0000ff" >
True</span>, <span style= "color: #006600" >//true-asynchronous transmission; false-Synchronous transmission </span>
<br/>
<span style= "color: #ff0000" > Form</span>: <span style= "color: #0000ff" >
Formobj</span>, <span style= "color: #006600" >//form objects, if set, the form is submitted with Ajax, and the Method,url and data properties of the settings are ignored </span>
<br/>
<span style= "color: #ff0000" >url</span>: <span style= "color: #660033" >
"" </SPAN> <span style= "color: #006600" >//This is a required value if you do not set the form property </span><br/>
<span style= "color: #ff0000" >datatype</span>: <span style= "color: #660033" >
"Text" </span>, <span style= "color: #33cc00" > <span style= "color: #006600" >//desirable value text,xml,json</span> </span><br/>
</span></span> <span style= "color: #ff0000" >method</span>: <span style= "color: #660033" >
"Get" </SPAN> <span style= "color: #006600" >//desirable post,get case-insensitive. When you set the form property, this item is ignored. </span>
<br/>
<span style= "color: #ff0000" >data</span>: <span style= "color: #660033" >
"" </SPAN> <span style= "color: #006600" >//specific format see the sample program. When you set the form property, this item is ignored. </span><br/>
<span style= "color: #ff0000" >timeout</span>: <span style= "color: #660033" >
10000</span>, <span style= "color: #006600" >//set timeout, default to 10 seconds (that is, 10000 milliseconds) </span><br/>
<span style= "color: #ff0000" >succeed</span>: <span style= "color: #0000ff" >
Function</span> (a,b,c) {<span style= "color: #0000ff" >return true</span>},
<br/>
<span style= "color: #ff0000" >error</span>: <span style= "color: #0000ff" >
Function</span> (a,b,c) {<span style= "color: #0000ff" >return true</span>},
<br/>
<span style= "color: #ff0000" >ontimeout</span>: <span style= "color: #0000ff" >
Function</span> (a,b,c) {<span style= "color: #0000ff" >return true</span>}
<br/>
};<br/>
</span>
</p>
</body>