Ajax+ASP和Flash+ASP数据读取取方法有些相似的实现方法

编程入门 行业动态 更新时间:2024-10-26 22:19:08
ajax+asp和flash+asp数据存取方法两种数据存取方法差不多。===============================下面是一个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) { //ietry{ajaxhttprequest = new activexobject("msxml2.xmlhttp");}catch(e) {try{ajaxhttprequest = new activexobject("microsoft.xmlhttp");}catch(e) {}}}if(!ajaxhttprequest) {window.alert("不能创建xmlhttprequest对象实例");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("请输入内容");}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("您请求的页面有异常");//alert("您请求的页面有异常");}}}

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;}}}}=================================下面是我一个flash留言的数据读取的部分代码: www.linjimu/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 正在读取留言数据...\n\n 请稍后...";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 = " 读取数据不成功!\n\n 可能发生以下错误:\n 1.

读取数据超时,请稍后再试.\n 2.空间不支持asp."+this.message;}} else {_root.gotoandplay("wait");_root.waitbttext = "返回留言";_root.frame = "send";_root.textmessage.text = " 读取数据不成功!\n\n 可能发生以下错误:\n 1.读取数据

超时,请稍后再试.\n 2.空间不支持asp.";}};delete ls;stop();================相比一下,他们都有相似之处:ajax:ajaxhttprequest.open("post",url,true);//发送数据的方法,类型,url地址..ajaxhttprequest.setrequestheader("content-type","application/x-www-form-urlencoded");ajaxhttprequest.send(values);//发送数据ajaxhttprequest.onreadystatechange = processrequest; //processrequest是一个过程函数,对返回数据的

处理。--------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");//发送数据的方法,类型,url地址..ld.onload = function(ok) {//code...} //也是一个过程函数,对返回数据的处理。

不过,在web方面,ajax的页面完全基于html,文本网页会更有利于搜索引擎的搜索。flash开发人员还是偏重图形、动画设计,flash能够更容易的调用浏览器以外的外部资源。比如摄像头、麦克风等。然而这是普通的html无法完成的。

他们的关系请去baidu一下:flash与ajax

  • 0
  • 0
  • 0
  • 0
  • 0

更多推荐

Ajax+ASP和Flash+ASP数据读取取方法有些相似的实现方法

本文发布于:2023-06-10 18:32:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/616432.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   数据   Ajax   ASP   Flash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!