Home Web Front-end JS Tutorial Detailed steps to update data without refreshing using javascript asp_javascript skills

Detailed steps to update data without refreshing using javascript asp_javascript skills

May 16, 2016 pm 07:22 PM
asp

In programming, we often encounter a situation where it is impossible to know in advance what data the user will need. The data must be re-extracted from the server based on the user's selection and fed back to the user. For example, in a simple case, after the user selects a province, we will immediately redisplay all the cities in the province in the city. In this case, it is generally necessary to refresh the entire page before re-reading it, but this is not only inefficient but also inelegant. In fact, by using JavaScript combined with the XMLHTTP object of Microsoft, we can read the data from the server "slightly" without refreshing, which looks both professional and efficient.
Below we will demonstrate this technology in a case of verifying whether the user is registered.
'Program design: Global Wanwei, a professional virtual host and domain name registration service provider
'Website: http://www.netInter.cn
'This program is Global Wanwei's original program, so if you If you need to reprint, please indicate the source, thank you.
'The above information is an integral part of the article text, so if you want to reprint this article, you must keep the above information.

1. First create a CheckUser.asp file on the server for Detect whether the user exists, and feedback 0 and 1 respectively according to whether the user exists
u_name=Request.QueryString("u_name")
if u_name exists then
Response.write "0"
else
Response.write "1"
end if
2. Client-side HTML design:
1. JavaScript code


2. HTML form design:





<script> <BR>function check_user_exists(form){ <BR>u_name=form.u_name.value; <BR>if (u_name==null||u_name==''){ <BR>alert("请您输入用户名"); <BR>return false; <BR>} <BR>infoBoard=document.getElementById("checkInfo"); <BR>infoBoard.innerText='查询中...'; <BR>myurl=location.protocol+"//"+location.hostname+"/CheckUser.asp?u_name="+u_name; <BR>retCode=openUrl(myurl); <BR>switch(retCode){ <BR>case "-2": <BR>infoBoard.innerHTML='<font color=red>抱歉,查询失败';break; <BR>case "1": <BR>infoBoard.innerHTML='<font color=red>恭喜,'+u_name+'可以使用';break; <BR>case "0": <BR>infoBoard.innerHTML='<font color=red>抱歉,用户名'+u_name+'已经被使用'; <BR>} <BR>return; <BR>} <br><br>function openurl(/url){ <BR>var objxml=new ActiveXObject("Microsoft.XMLHttp") <BR>objxml.open("GET",url,false); <BR>objxml.send(); <BR>retInfo=objxml.responseText; <BR>if (objxml.status=="200"){ <BR>return retInfo; <BR>} <BR>else{ <BR>return "-2"; <BR>} <BR>} <BR></script>After the above three steps, a data update program that does not require page refresh is completed (demo address: http:/ /www.web9898.cn/reg), according to this method, you can realize many cool applications:)
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What are the built-in objects in asp? What are the built-in objects in asp? Nov 09, 2023 am 11:32 AM

ASP built-in objects include Request, Response, Session, Application, Server, Session.Contents, Application.Contents, Server.CreateObject, Server.MapPath, Server.Execute, Server.Transfer, etc. Detailed introduction: 1. Request: represents HTTP request object, etc.

What are the asp development tools? What are the asp development tools? Oct 23, 2023 am 11:02 AM

ASP development tools include Visual Studio, Dreamweaver, FrontPage, EditPlus, UltraEdit, SQL Server Management Studio, RAD Studio, Delphi, Asp.NET and Oracle SQL Developer.

asp scanning tool vulnerability detection asp scanning tool vulnerability detection Oct 13, 2023 am 10:45 AM

ASP scanning tool vulnerability detection: 1. Select the appropriate scanning tool; 2. Configure the scanning target in the scanning tool; 3. Configure scanning options as needed; 4. After the configuration is completed, start the scanning tool to start scanning; 5. Scanning tool A report will be generated listing the detected vulnerabilities and security issues; 6. Fix the detected vulnerabilities and security issues according to the recommendations in the report; 7. After fixing the vulnerability, re-run the scanning tool to ensure that the vulnerability has been successfully exploited repair.

How to manually detect vulnerabilities in asp How to manually detect vulnerabilities in asp Oct 13, 2023 am 10:49 AM

ASP manual detection of vulnerabilities: 1. Check the ASP application's verification and filtering mechanism for user input; 2. Check the ASP application's encoding and filtering mechanism for output data; 3. Check the ASP application's authentication and session management mechanism; 4. Check the ASP application's permission control on files and directories; 5. Check the ASP application's handling of errors; 6. Check the ASP application's database security; 7. Check the ASP application's configuration file and server configuration.

What are the methods for detecting asp vulnerabilities? What are the methods for detecting asp vulnerabilities? Oct 13, 2023 am 10:42 AM

Methods include: 1. Use specialized vulnerability scanning tools; 2. Manual testing to discover and verify vulnerabilities in ASP applications; 3. Conduct security audits to check the code and configuration files of ASP applications; 4. Use vulnerability exploitation frameworks; 5. Review the code of the ASP application.

How to connect asp to access database How to connect asp to access database Oct 18, 2023 am 11:33 AM

Connection method: 1. Use ADO to connect to the database; 2. Use DSN to connect to the database; 3. Use the connection string to connect to the database.

iPhone average selling price rises 14% as iPhone 13 drives record revenue iPhone average selling price rises 14% as iPhone 13 drives record revenue Apr 14, 2023 pm 03:22 PM

iPhone average selling price (ASP) achieved double-digit growth last year, growing 14% year-on-year. The popularity of iPhone 13 is a key driver, helping push the global smartphone market as a whole to a record annual revenue of $448B. Despite parts shortages, the smartphone market grew 7% year-on-year, with Apple taking by far the largest share... Market intelligence firm Counterpoint released its latest estimates today. According to the latest research from Counterpoint's MarketMonitorService, the global smartphone market revenue will exceed US$448 billion in 2021. Even as component shortages and COVID-19 restrictions continue to disrupt global supply

How to do asp security audit vulnerability detection How to do asp security audit vulnerability detection Oct 13, 2023 am 10:54 AM

ASP security audit vulnerability detection steps: 1. Collect relevant information about the ASP application; 2. Carefully analyze the source code of the ASP application; 3. Check the ASP application's verification and filtering mechanism for user input; 4. Check the application's Encoding and filtering mechanism of output data; 5. Check the application's authentication and session management mechanism; 6. Check the application's permission control on files and directories; 7. Check the application's handling of errors; 8. Check the application's Configuration files and server configuration; 9. Fix vulnerabilities.

See all articles