Using XMLHTTP to add data without refreshing

Source: Internet
Author: User
Tags add end http request sql return string
xml| Data | refresh | No refresh this article can be used as your first example of Ajax learning textbook. No refresh technology implementation, please be sure to have the necessary conditions to use, it may cause you unnecessary trouble. Our traditional methods of submitting data are implemented by .
The method property in the 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


This article uses XMLHTTP to realize the form's method=post.


Clientpost.htm




Userid:

Username:

Server.asp server-side processing.

<% @Language = "JavaScript"%>
<%
function Opendb (sdbname)
{
/*
*---------------opendb (sdbname)-----------------
* OPENDB (Sdbname)
* Function: Open database Sdbname, return conn object.
* Parameters: Sdbname, String, database name.
* Example: var conn = opendb ("Database.mdb");
*---------------opendb (sdbname)-----------------
*/
var connstr = "Provider=Microsoft.Jet.OLEDB.4.0;" Data source= "+server.mappath (sdbname);
var conn = Server.CreateObject ("ADODB.") Connection ");
Conn. Open (CONNSTR);
Return conn;
}
var sresult = "";
var oconn = opendb ("Data.mdb");
//equivalent to the method=post of form.
Equivalent to the form of the method=post.
Special characters: +,%,&,=, etc. transmission solutions. The client is transmitted over the escape code.
So the end of the receiver should be unescape decoding first.
Update:2004-6-1 12:22
Unescape (Request.Form ("userid")) ...
var userid = unescape (Request.Form ("userid"));
var username = unescape (Request.Form ("username"));
Sresult = "UserID: +userid+" \nusername: "+username+" \ n Add success. "
var sql = "Insert into users (userid,username) Values (' +userid+" ', ' "+username+ ')";
Oconn.execute (SQL);
Response.Write (Escape (Sresult));
%>


Database design
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.