YouTip LogoYouTip

Asp Ajax Database

-- Learn not only technology, but also dreams! Home HTML JAVASCRIPT CSS VUE REACT PYTHON3 JAVA C C++ C# AI GO SQL LINUX VS CODE BOOTSTRAP GIT Local Bookmarks ASP Tutorial ASP Tutorial ASP Introduction ASP Installation ASP Syntax ASP Variables ASP Procedures ASP Forms ASP Cookies ASP Session ASP Application ASP #include ASP Global.asa ASP Send Email ASP Objects ASP Response ASP Request ASP Application ASP Session ASP Server ASP Error ASP FileSystem ASP TextStream ASP Drive ASP File ASP Folder ASP Dictionary ASP ADO ASP Components ASP AdRotator ASP BrowserCap ASP Content Linking ASP Content Rotator ASP and AJAX AJAX Introduction AJAX ASP AJAX Database ASP Summary ASP Quick Reference ASP Summary ASP Examples ASP Examples ASP – AJAX with ASP ASP Quick Reference Deep Dive Network Script Data Management Computer Hardware Scripting Languages Computer Servers Computer Programming Computer Script AJAX Database Example AJAX can be used to interactively communicate with a database. AJAX Database Example The following example demonstrates how a web page fetches information from a database via AJAX: Example Select a customer: Alfreds Futterkiste North/South Wolski Zajazd Customer info will be listed here... Example Explanation - HTML Page When a user selects a customer in the dropdown list above, a function called "showCustomer()" is executed. This function is triggered by the "onchange" event: function showCustomer(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getcustomer.asp?q="+str,true); xmlhttp.send(); } </head Select a customer: Alfreds Futterkiste North/South Wolski Zajazd
Customer info will be listed here...
Source Code Explanation: If no customer is selected (str.length==0), the function clears the txtHint placeholder and exits the function. If a customer is selected, the showCustomer() function performs the following steps: Create an XMLHttpRequest object Create the function to be executed when the server response is ready Send a request to a file on the server Note the parameter (q) added to the end of the URL (containing the content of the dropdown list) ASP File The server page called by JavaScript above is an ASP file named "getcustomer.asp". The source code in "getcustomer.asp" runs a query against the database and returns the results in an HTML table: <% response.expires=-1 sql="SELECT * FROM CUSTOMERS WHERE CUSTOMERID=" sql=sql & "'" & request.querystring("q") & "'" set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open(Server.Mappath("/db/northwind.mdb")) set rs=Server.CreateObject("ADODB.recordset") rs.Open sql,conn response.write("") do until rs.EOF for each x in rs.Fields response.write("") response.write("") next rs.MoveNext loop response.write("
" & x.name & "" & x.value & "
") %> ASP – AJAX with ASP ASP Quick Reference Byte Ark Coding Plan Supports mainstream large models including Doubao, GLM, DeepSeek, Kimi, MiniMax, officially supplied and stable. Β₯9.9 /month Activate Now iFlytek Star Coding Plan Includes free model call quota, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform. Β₯3.9 /month Activate Now Click to Share Notes Category Navigation Python / Data Science AI / Intelligent Development Front-end Development Back-end Development Database Mobile Development DevOps / Engineering Programming Languages Computer Basics XML / Web Service .NET Website Building Advertisement ASP Tutorial ASP Tutorial ASP Introduction ASP Installation ASP Syntax ASP Variables ASP Procedures ASP Forms ASP Cookies ASP Session ASP Application ASP #include ASP Global.asa ASP Send Email ASP Objects ASP Response ASP Request ASP Application ASP Session ASP Server ASP Error ASP FileSystem ASP TextStream ASP Drive ASP File ASP Folder ASP Dictionary ASP ADO ASP Components ASP AdRotator ASP BrowserCap ASP Content Linking ASP Content Rotator ASP and AJAX AJAX Introduction AJAX ASP AJAX Database ASP Summary ASP Quick Reference ASP Summary ASP Examples ASP Examples Online Examples Β·HTML Examples Β·CSS Examples Β·JavaScript Examples Β·Ajax Examples Β·jQuery Examples Β·XML Examples Β·Java Examples Character Sets & Tools Β· HTML Character Set Settings Β· HTML ASCII Character Set Β· JS Obfuscation/Encryption Β· PNG/JPEG Image Compression Β· HTML Color Picker Β· JSON Formatting Tool Β· Random Number Generator Latest Updates Β· Dart Enums and Symbols Β· Dart Unit Testing Β· Dart Concurrency and Iso... Β· Dart Stream Β· Dart Asynchronous Programming Β· Dart typedef and... Β· Dart Packages and Library Management Site Information Β· Feedback Β· Disclaimer Β· About Us Β· Article Archive Follow WeChat My Favorites Bookmark Article Browsing History Clear All No records
← Asp QuickrefAsp Ajax Asp β†’