Ajax+ASP和Flash+ASP數(shù)據(jù)讀取取方法有些相似的實(shí)現(xiàn)方法
兩種數(shù)據(jù)存取方法差不多。
===============================
下面是一個(gè)ChatRoom的Ajax部分代碼:
var ajaxHttpRequest = false;
function ajaxInit() {
if(window.XMLHttpRequest) { //Mozilla, Opera, ...
ajaxHttpRequest = new XMLHttpRequest();
if(ajaxHttpRequest.overrideMimeType) {
ajaxHttpRequest.overrideMimeType("text/xml");
}
}
else if(window.ActiveXObject) { //IE
try{
ajaxHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e) {
try{
ajaxHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e) {
}
}
}
if(!ajaxHttpRequest) {
window.alert("不能創(chuàng)建XMLHttpRequest對(duì)象實(shí)例");
return false;
}
}
function ajaxSendPost(url, values, processRequest) {
ajaxHttpRequest.open("POST",url,true);
ajaxHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajaxHttpRequest.send(values);
ajaxHttpRequest.onreadystatechange = processRequest;
}
/*
function ajaxSendGet(url) {
ajaxHttpRequest.open("GET",url,true);
ajaxHttpRequest.send(null);
ajaxHttpRequest.onreadystatechange = processRequest;
}
*/
ajaxInit();
var sound = false;
var isMove = true;
function send() {
var msg=escape((document.getElementById("msg")).value); //escape解決Ajax中文籌碼問題
if(msg=="") {
setSuggest("請(qǐng)輸入內(nèi)容");
}
else {
var color = document.getElementById("selectColor").value;
var values = "msg=" + msg + "&color=" + color;
ajaxSendPost("process.asp", values, processSendRequest);
document.getElementById("msg").value = "";
document.getElementById("msg").focus();
}
}
function processSendRequest() {
if(ajaxHttpRequest.readyState==4) {
if(ajaxHttpRequest.status==200) {
if(ajaxHttpRequest.responseText!="") {
var chatContent = document.getElementById("chat_content");
var msgDiv = document.createElement("div");
msgDiv.innerHTML = ajaxHttpRequest.responseText;
chatContent.appendChild(msgDiv);
sound = true;
}
}
else {
setSuggest("您請(qǐng)求的頁面有異常");
//alert("您請(qǐng)求的頁面有異常");
}
}
}
function getAllMsg() {
setSuggest(" ");
ajaxSendPost("process.asp","",processSendRequest);
if(sound) {
setSuggest("<embed type=\"application/x-mplayer2\" src=\"sound/message.wav\"
autostart=\"true\" loop=\"false\" height=0 width=0 /> ");
sound=false;
}
}
function IamComing() {
ajaxSendPost("iamcoming.asp", "", processSendRequest);
(document.getElementById("msg")).focus();
}
function showOnline() {
ajaxSendPost("showOnline.asp", "", processShowOnline);
}
function processShowOnline() {
if(ajaxHttpRequest.readyState==4) {
if(ajaxHttpRequest.status==200) {
if(isFinite(ajaxHttpRequest.responseText)) {
document.getElementById("online").innerHTML =
ajaxHttpRequest.responseText;
}
}
}
}
=================================
下面是我一個(gè)Flash留言的數(shù)據(jù)讀取的部分代碼: http://www.linjimu.com.cn/Flash
ls = new LoadVars();
ls.Action = "Read";
ls.CurrentPage = _root.CurrentPage;
//ls load and send ,ld load result;
ld = new LoadVars();
ls.sendAndLoad("Advice.asp", ld, "post");
_root.gotoAndPlay("Wait");
_root.WaitBtText = "返回留言";
_root.Frame = "Send";
_root.TextMessage.text = "\n 正在讀取留言數(shù)據(jù)...\n\n 請(qǐng)稍后...";
ld.onLoad = function(ok) {
if (ok) {
if (this.message == "OK") {
_root.gotoAndPlay("ListView");
} else {
_root.gotoAndPlay("Wait");
_root.WaitBtText = "返回留言";
_root.Frame = "Send";
_root.TextMessage.text = " 讀取數(shù)據(jù)不成功!\n\n 可能發(fā)生以下錯(cuò)誤:\n 1.
讀取數(shù)據(jù)超時(shí),請(qǐng)稍后再試.\n 2.空間不支持ASP."+this.message;
}
} else {
_root.gotoAndPlay("Wait");
_root.WaitBtText = "返回留言";
_root.Frame = "Send";
_root.TextMessage.text = " 讀取數(shù)據(jù)不成功!\n\n 可能發(fā)生以下錯(cuò)誤:\n 1.讀取數(shù)據(jù)
超時(shí),請(qǐng)稍后再試.\n 2.空間不支持ASP.";
}
};
delete ls;
stop();
================
相比一下,他們都有相似之處:
AJax:
ajaxHttpRequest.open("POST",url,true);//發(fā)送數(shù)據(jù)的方法,類型,url地址..
ajaxHttpRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
ajaxHttpRequest.send(values);//發(fā)送數(shù)據(jù)
ajaxHttpRequest.onreadystatechange = processRequest; //processRequest是一個(gè)過程函數(shù),對(duì)返回?cái)?shù)據(jù)的
處理。
--------
Flash:
ls = new LoadVars();
ls.Action = "Read";//是發(fā)送數(shù)據(jù)
ls.CurrentPage = _root.CurrentPage;//是發(fā)送數(shù)據(jù)
//ls load and send ,ld load result;
ld = new LoadVars();
ls.sendAndLoad("Advice.asp", ld, "post");//發(fā)送數(shù)據(jù)的方法,類型,url地址..
ld.onLoad = function(ok) {//code...} //也是一個(gè)過程函數(shù),對(duì)返回?cái)?shù)據(jù)的處理。
不過,在web方面,Ajax的頁面完全基于HTML,文本網(wǎng)頁會(huì)更有利于搜索引擎的搜索。
Flash開發(fā)人員還是偏重圖形、動(dòng)畫設(shè)計(jì),F(xiàn)lash能夠更容易的調(diào)用瀏覽器以外的外部資源。比如攝像頭、麥克風(fēng)等。然而這是普通的HTML無法完成的。
他們的關(guān)系請(qǐng)去baidu一下:flash與AJAX http://www.baidu.com/s?wd=flash+ajax
相關(guān)文章
msxml3.dll 錯(cuò)誤 800c0019 系統(tǒng)錯(cuò)誤:-2146697191解決方法
今天發(fā)現(xiàn)一個(gè)asp后臺(tái)使用了XMLHTTP組件的頁面無法無法生成靜態(tài)頁面了,運(yùn)行時(shí)提示msxml3.dll 錯(cuò)誤 800c0019 系統(tǒng)錯(cuò)誤:-2146697191,經(jīng)過搜索如下方法解決了問題2020-11-11ASP新聞分頁,將一篇過長(zhǎng)的文章分頁,生成靜態(tài)頁面
現(xiàn)在將他們生成靜態(tài)頁面沒有什么問題,但是如何將它們按照某種規(guī)則,生成編號(hào)為20030405-1.htm 20030405-2.htm 20030405-3.htm這樣的靜態(tài)文件呢?2008-11-11ASP Access實(shí)現(xiàn)網(wǎng)站計(jì)數(shù)器(訪問量)
學(xué)習(xí)asp的朋友需要了解下2008-11-11SQL"不能為新插入的行確定標(biāo)識(shí)"錯(cuò)誤的解決方法
下列代碼運(yùn)行將出錯(cuò)(不能為新插入的行確定標(biāo)識(shí)),即新記錄不能為自己的另一個(gè)字段賦予新生成標(biāo)識(shí)的值2008-10-10asp中讓function同時(shí)返回多個(gè)值的代碼
asp中讓function同時(shí)返回多個(gè)值的代碼,需要的朋友可以參考下。2011-02-02Dom遍歷XML的一個(gè)例子,結(jié)果為樹狀結(jié)構(gòu)
Dom遍歷XML的一個(gè)例子,結(jié)果為樹狀結(jié)構(gòu)...2007-01-01Js獲取asp頁面返回的值(加載值)實(shí)現(xiàn)代碼
本文詳細(xì)介紹Js獲取asp頁面返回的值(加載值)實(shí)現(xiàn)方法,需要了解的朋友可以參考下2012-12-12