ASP Ajax Instance (post,get,form test) (1/3)

Source: Internet
Author: User
Tags json servervariables

The article provides a simple ASP tutorial Ajax example (post,get,form test) Oh, he did three related Ajax ASP test examples, all passed.

Index.html

<!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"/>&nbsp; "
<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/>
&nbsp; &nbsp;<span style= "color: #ff0000" > Asc</span&gt: <span style= "color: #0000ff" >
True</span&gt, &nbsp; &nbsp;<span style= "color: #006600" >//true-asynchronous transmission; false-Synchronous transmission </span>
<br/>
&nbsp; &nbsp;<span style= "color: #ff0000" > Form</span&gt: <span style= "color: #0000ff" >
Formobj</span&gt, &nbsp; &nbsp;<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/>
&nbsp; &nbsp; <span style= "color: #ff0000" >url</span&gt: <span style= "color: #660033" >
"" &LT;/SPAN&GT; &nbsp; &nbsp;<span style= "color: #006600" >//This is a required value if you do not set the form property </span><br/>
&nbsp; &nbsp; <span style= "color: #ff0000" >datatype</span&gt: <span style= "color: #660033" >
"Text" </span&gt, &nbsp; &nbsp;<span style= "color: #33cc00" > <span style= "color: #006600" >//desirable value text,xml,json</span> </span><br/>
</span></span>&nbsp; &nbsp; <span style= "color: #ff0000" >method</span&gt: <span style= "color: #660033" >
"Get" &LT;/SPAN&GT; &nbsp; &nbsp;<span style= "color: #006600" >//desirable post,get case-insensitive. When you set the form property, this item is ignored. </span>
<br/>
&nbsp; &nbsp; <span style= "color: #ff0000" >data</span&gt: <span style= "color: #660033" >
"" &LT;/SPAN&GT; &nbsp; &nbsp;<span style= "color: #006600" >//specific format see the sample program. When you set the form property, this item is ignored. </span><br/>
&nbsp; &nbsp; <span style= "color: #ff0000" >timeout</span&gt: <span style= "color: #660033" >
10000</span&gt, &nbsp; &nbsp;<span style= "color: #006600" >//set timeout, default to 10 seconds (that is, 10000 milliseconds) </span><br/>
&nbsp; &nbsp; <span style= "color: #ff0000" >succeed</span&gt: <span style= "color: #0000ff" >
Function</span> (a,b,c) {<span style= "color: #0000ff" >return true</span>},
<br/>
&nbsp; &nbsp; <span style= "color: #ff0000" >error</span&gt: <span style= "color: #0000ff" >
Function</span> (a,b,c) {<span style= "color: #0000ff" >return true</span>},
<br/>
&nbsp; &nbsp; <span style= "color: #ff0000" >ontimeout</span&gt: <span style= "color: #0000ff" >
Function</span> (a,b,c) {<span style= "color: #0000ff" >return true</span>}
<br/>
};<br/>
</span>
</p>

</body>

Home 1 2 3 last
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.