Add a get piece of data without refreshing with XMLHTTP

Source: Internet
Author: User
xml| Data | refresh | Without refreshing our traditional methods of submitting data are implemented by <Form>.
The method property in the <Form> tag determines that the data for the form element is sent to the server
How to package HTTP request information.

Method property can be used
Method property to send form elements to read the request collection of data
Get identity at the end of URL querystring
Post in the body of the HTTP request (the free area of the HTTP request) Form



<scriptlanguage= "JavaScript" >
Functionadddataget (Suserid,susername)
{
/*
*---------------Adddataget (suserid,susername)-----------------
*adddataget (Suserid,susername)
* Function: Add data through XMLHTTP. Equivalent to the form of the method=get.
* Parameter: sUserID, string, send condition.
* Parameter: sUserName, string, send condition.
* Example: Adddataget (Document.all.userid.value,document.all.username.value);
*---------------Adddataget (suserid,susername)-----------------
*/
Varobao=newactivexobject ("Microsoft.XMLHTTP");
Special characters: +,%,&,=, etc. transmission solutions. Use escape code.
Update:2004-6-112:22
Escape (sUserID), Escape (sUserName);
Obao.open ("POST", "server.asp?userid=" +escape (sUserID) + "&username=" +escape (sUserName), false);
Obao.send ();

Document.all.userid.value= "";
Document.all.username.value= "";

Alert ()
}
</script>
<inputtype= "button" value= "Adddataget" ><br>
Userid:<inputtype= "text" name= "userid" ><br>
Username:<inputtype= "text" name= "username" >

<% @Language = "JavaScript"%>
<%
FUNCTIONOPENDB (Sdbname)
{
/*
*---------------opendb (sdbname)-----------------
*OPENDB (Sdbname)
* Function: Open database Sdbname, return conn object.
* Parameters: Sdbname, String, database name.
* Example: Varconn=opendb ("Database.mdb");
*---------------opendb (sdbname)-----------------
*/
Varconnstr= "provider=microsoft.jet.oledb.4.0;datasource=" +server.mappath (sdbname);
Varconn=server.createobject ("ADODB.") Connection ");
Conn. Open (CONNSTR);
Returnconn;
}
Varsresult= "";
Varoconn=opendb ("Data.mdb");

Equivalent to the form of the method=get.
Special characters: +,%,&,=, etc. transmission solutions. The client is transmitted over the escape code.
So the end of the receiver should be decoded first with unescape.
Update:2004-6-112:22
Unescape (Request.QueryString ("userid")) ...
Varuserid=unescape (Request.QueryString ("userid"));
Varusername=unescape (Request.QueryString ("username"));
sresult= "userid: +userid+" \nusername: "+username+" \ n Add success. "
Varsql= "Insertintousers (userid,username) Values (' +userid+" ', ' "+username+ ')";
Oconn.execute (SQL);
Response.Write ();
%>



Data.mdb
Table users.
Field
ID Auto Number
UserID text
Username text

Table: Users data:
ID userid Username
1 wanghr100 Administrator



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.