<< Chapter < Page Chapter >> Page >

// on IE, we have to use ActiveX

ro = new ActiveXObject("Microsoft.XMLHTTP");

} else {

// on every other browser, we can directly create a new XMLHttpRequest object

ro = new XMLHttpRequest();

}

return ro;

}

var http = createRequestObject();

// this function should be called for user input

// the response in this case is formatted as follows:

// object|text

// where object is the id of the HTML element we are going to update

// and text is what it will be updated to

// this could obviously work a lot better with some XML

function handleResponse()

{

if(http.readyState == 4) {

var response = http.responseText;

var update = new Array();

if(response.indexOf('|' != -1)) {

update = response.split("|");

document.getElementById(update[0]).innerHTML = update[1];

}

}

}

// this function should be called for user input

// it opens up the usercheck.asp page with a querystring of 'action'

function sndUserCheck(action)

{

http.open("get", "searchMeaning.asp?formWord=" + action);

http.onreadystatechange = handleResponse;

http.send(null);

}

Tệp ajax_search.js

//Gets the browser specific XmlHttpRequest Object

function getXmlHttpRequestObject() {

if (window.XMLHttpRequest) {

return new XMLHttpRequest();

} else if(window.ActiveXObject) {

return new ActiveXObject("Microsoft.XMLHTTP");

} else {

alert("Your Browser Sucks!\nIt's about formWorde to upgrade don't you think?");

}

}

//Our XmlHttpRequest object to get the auto suggest

var searchReq = getXmlHttpRequestObject();

//Called from keyup on the search textbox.

//Starts the AJAX request.

function searchSuggest() {

if (searchReq.readyState == 4 || searchReq.readyState == 0) {

var str = escape(document.getElementById('formWord').value);

searchReq.open("GET", 'searchSuggest.asp?formWord=' + str, true);

searchReq.onreadystatechange = handleSearchSuggest;

searchReq.send(null);

}

}

//Called when the AJAX response is returned.

function handleSearchSuggest() {

if (searchReq.readyState == 4) {

var ss = document.getElementById('search_suggest')

ss.innerHTML = '';

var str = searchReq.responseText.split("<br>");

for(i=0; i<str.length - 1; i++) {

//Build our element string. This is cleaner using the DOM, but

//IE doesn't support dynamically added attributes.

var suggest = '<div onmouseover="javascript:suggestOver(this);" ';

suggest += 'onmouseout="javascript:suggestOut(this);" ';

suggest += 'onclick="javascript:setSearch(this.innerHTML);" ';

suggest += 'class="suggest_link">' + str[i] + '</div>';

ss.innerHTML += suggest;

}

}

}

//Mouse over function

function suggestOver(div_value) {

div_value.className = 'suggest_link_over';

}

//Mouse out function

function suggestOut(div_value) {

div_value.className = 'suggest_link';

}

//Click function

function setSearch(value) {

document.getElementById('formWord').value = value;

document.getElementById('search_suggest').innerHTML = '';

}

Tệp search_suggest.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Module tu dien</title>

</head>

<%

//Writen by Minhdn

//Lay bien search bang request, sau do search trong CSDL

//nhung dong nao co title like bien search thi lay ra

%>

<!--#include file="connection.asp"-->

<%///Make sure that a value was sent.

formWord=request("formWord")

//Get every page title for the site.

if len(formWord)>=1 then

str = "SELECT * FROM dictionary WHERE word like '"&formWord&"%' ORDER BY word"

rs.open str,conn

do until rs.eof%>

<%=rs("word")%><br>

<%rs.movenext

loop

rs.close

set rs=nothing

end if

%>

Tệp search_mearning.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

dim strConn, dbConn, RS

set dbconn= server.createObject("ADODB.connection")

dbConn.Open "PROVIDER=MSDASQL;DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.Mappath("dictionary.mdb")

set rs = server.createobject("ADODB.recordset")

'query the database

str="SELECT * FROM dictionary WHERE word = '"&

request.querystring("formWord")&"'"

set RS = dbConn.execute(str)

'is this name taken or not

if not RS.eof then

response.write "TakenOrNot|<b>"&request.querystring("formWord")&":</b><br>"&rs("meaning")

else

response.write "TakenOrNot|Thong bao: "&"Khong co tu nay"

'end if

end if

%>

Tương tự như vậy, các ứng dụng kiểm tra tên đăng nhập (người dùng chọn tên đăng nhập và check xem tên đó đã có chưa), tự động sao lưu văn bản đang soạn thảo (auto save), tự động sao lưu nội dung làm việc của người dùng (ví dụ điền form)… cũng được thực hiện thông qua cơ chế này.

Chúc các bạn thành công

Questions & Answers

where we get a research paper on Nano chemistry....?
Maira Reply
what are the products of Nano chemistry?
Maira Reply
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
Google
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
Preparation and Applications of Nanomaterial for Drug Delivery
Hafiz Reply
revolt
da
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
Jyoti Reply
I only see partial conversation and what's the question here!
Crow Reply
what about nanotechnology for water purification
RAW Reply
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
Brian Reply
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
LITNING Reply
what is a peer
LITNING Reply
What is meant by 'nano scale'?
LITNING Reply
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
Bob Reply
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
Damian Reply
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
Stoney Reply
why we need to study biomolecules, molecular biology in nanotechnology?
Adin Reply
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
Adin
why?
Adin
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
how did you get the value of 2000N.What calculations are needed to arrive at it
Smarajit Reply
Privacy Information Security Software Version 1.1a
Good
Got questions? Join the online conversation and get instant answers!
Jobilize.com Reply

Get the best Algebra and trigonometry course in your pocket!





Source:  OpenStax, Giáo trình tổng quan về ajax và wap. OpenStax CNX. Jul 30, 2009 Download for free at http://cnx.org/content/col10828/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Giáo trình tổng quan về ajax và wap' conversation and receive update notifications?

Ask