| 订阅 | 在线投稿
分享
 
 
当前位置: 王朝网络 >> php >> Ajax+PHP jian dan ru men jiao cheng

Ajax+PHP jian dan ru men jiao cheng

2008-12-22 08:10:49 编辑來源:互联网 评论
 
 
 
本文为【Ajax+PHP简单入门教程】的拼音翻译版
  Ajax you HTML、JavaScript™ ji shu 、DHTML he DOM zu cheng , zhe yi jie chu de fang fa ke yi jiang ben zhuo de Web jie mian zhuan hua cheng jiao hu xing de Ajax ying yong cheng xu 。 dui yu Ajax, zui gai xin de yi ge dui xiang shi XMLHttpRequest, suo you de Ajax cao zuo dou li bu kai dui zhe ge dui xiang de cao zuo 。
  shou xian wo men lai le jie zen me zai javascript zhong chuang jian zhe ge dui xiang :
  varxmlHttp=newXMLHttpRequest();
  zhe xing jian dan de dai ma zai Mozilla、Firefox、Safari、Opera yi ji ji ben shang suo you yi ren he xing shi huo fang shi zhi chi Ajax de fei Microsoft liu lan qi zhong , chuang jian le XMLHttpRequest dui xiang 。 dan shi dui yu shi chang zhan you lv da dao 70% de IE lai shuo , zhe zhong fang fa shi bu xing de , er bu tong de IE ban ben huan you bu tong de chuang jian fang fa , suo yi wo men xu yao zai IE xia mian shi yong xia mian liang zhong chuang jian dui xiang de ban fa :
  try{
  xmlHttp=newActiveXObject("Msxml2.XMLHTTP");// zhen dui jiao xin de liu lan qi
  }catch(err){
  try{
  xmlHttp=newActiveXObject("Microsoft.XMLHTTP");// zhen dui jiao lao de liu lan qi
  }catch(err2){
  xmlHttp=false;
  }
  }
  ji shi zhe yang , wo men ye wu fa yu liao you xie liu lan qi ke neng wu fa chuang jian zhe ge dui xiang , suo yi zai chuang jian bu cheng gong de qing kuang xia , wo men huan yao jia shang yi ju :
  if(!xmlHttp){
  alert(" wu fa chuang jian XMLHttpRequest dui xiang !");
  }
  jie he qi lai jiu shi :
  varxmlHttp=false;
  try{
  xmlHttp=newXMLHttpRequest();
  }catch(trymicrosoft){
  try{
  xmlHttp=newActiveXObject("Msxml2.XMLHTTP");
  }catch(othermicrosoft){
  try{
  xmlHttp=newActiveXObject("Microsoft.XMLHTTP");
  }catch(failed){
  xmlHttp=false;
  }
  }
  }
  if(!xmlHttp){
  alert(" wu fa chuang jian XMLHttpRequest dui xiang !");
  }
  ran hou , rang wo men jian li yi ge han shu getInfo(), da kai yi bu qing qiu :
  functiongetInfo(){
  varnum=document.getElementById("num").value;// huo de biao dan de shu ju
  varurl="/ajax/1.php?n="+escape(num);
  xmlHttp.open("GET",url,true);// zhe li de true dai biao shi yi bu qing qiu
  }
  yi dan yong open() pei zhi hao zhi hou , jiu ke yi fa song qing qiu le 。 sui ran ke yi shi yong send() fa song shu ju , dan ye neng tong guo URL ben shen fa song shu ju 。 shi shi shang , zai da bu fen GET qing qiu zhong , yong URL fa song shu ju yao rong yi de duo , suo yi zhe li yong null zuo wei send() de shen shu jiu ke yi le 。url di zhi li mian de php wen jian shi bei qing qiu lai chu li suo xu yao shu ju de php wen jian , jiu xiang wo men ping shi yong PHP de shi hou yi yang , hou mian de shen shu ke yi jia duo ge , bing yong & fen ge kai lai 。
  xmlHttp.send(null);
  zai fa song le shu ju zhi hou , wo men xu yao yong hui tiao fang fa lai huo de fu wu qi de zhuang tai , suo yi jiu yong dao le onreadystatechange shu xing 。
  xmlHttp.onreadystatechange=updatePage;
  ci yu ju yi jing yao fang zai send() yu ju qian mian , zhe yang cai hui you xiao , hou mian de updatePage shi chu li fan hui xin xi de yi ge han shu 。 wan zheng de getInfo() ru xia :
  functiongetInfo(){
  varnum=document.getElementById("num").value;// huo de biao dan de shu ju
  varurl="/ajax/1.php?n="+escape(num);
  xmlHttp.open("GET",url,true);// zhe li de true dai biao shi yi bu qing qiu
  xmlHttp.onreadystatechange=updatePage;
  xmlHttp.send(null);
  }
  wo men huan xu yao zai html li mian lai chu fa zhe ge han shu :
  <inputname="num"id="num"onblur="getInfo()"type="text"/>
  xia mian wo men xu yao lai bian xie updatePage() zhe ge han shu :
  functionupdatePage(){
  if(xmlhttp.readyState==4){
  varresponse=xmlhttp.responseText;
  document.getElementById("city").value=response;
  }
  }
  shang mian zhe duan dai ma li mian de readyState shi fu wu qi fan hui de yi ge zhuang tai ,4 zhe ge zhuang tai biao shi qing qiu yi jing fa song , bing chu li wan bi 。responseText shi huo de fu wu qi fan hui de xin xi , ran hou tong guo javascript fu gei ID wei city de biao dan 。
  dao ci , yi ge jian dan de Ajax cheng xu jiu wan cheng le , wan zheng de javascript dai ma ru xia :
  varxmlHttp=false;
  try{
  xmlHttp=newXMLHttpRequest();
  }catch(trymicrosoft){
  try{
  xmlHttp=newActiveXObject("Msxml2.XMLHTTP");
  }catch(othermicrosoft){
  try{
  xmlHttp=newActiveXObject("Microsoft.XMLHTTP");
  }catch(failed){
  xmlHttp=false;
  }
  }
  }
  if(!xmlHttp){
  alert(" wu fa chuang jian XMLHttpRequest dui xiang !");
  }
  functiongetInfo(){
  varnum=document.getElementById("num").value;// huo de biao dan de shu ju
  varurl="/ajax/1.php?n="+escape(num);
  xmlHttp.open("GET",url,true);// zhe li de true dai biao shi yi bu qing qiu
  xmlHttp.onreadystatechange=updatePage;
  xmlHttp.send(null);
  }
  functionupdatePage(){
  if(xmlhttp.readyState==4){
  varresponse=xmlhttp.responseText;
  document.getElementById("city").value=response;
  }
  }
  zhe li huan que yi ge php wen jian , you yu chu li de fang shi bu yi yang , xie fa ye bu yi yang , er qie zhe bu shi Ajax de zhu yao bu fen , suo yi zhe li jiu bu fang dai ma le 。 zhi yao ji zhu php shi shu chu bing fan hui suo xu yao de shu ju jiu ke yi le
  hao jiu mei geng xin , jin tian kan dao zhe jiao cheng , dui chu xue zhe ting shi he .【原文】【汉音对照
 
 
 
 
 
 
 
 
 
日版宠物情人插曲《Winding Road》歌词

日版宠物情人2017的插曲,很带节奏感,日语的,女生唱的。 最后听见是在第8集的时候女主手割伤了,然后男主用嘴帮她吸了一下,插曲就出来了。 歌手:Def...

兄弟共妻,我成了他们夜里的美食

老钟家的两个儿子很特别,就是跟其他的人不太一样,魔一般的执着。兄弟俩都到了要结婚的年龄了,不管自家老爹怎么磨破嘴皮子,兄弟俩说不娶就不娶,老父母为兄弟两操碎了心...

如何磨出破洞牛仔裤?牛仔裤怎么剪破洞?

把牛仔裤磨出有线的破洞 1、具体工具就是磨脚石,下面垫一个硬物,然后用磨脚石一直磨一直磨,到把那块磨薄了,用手撕开就好了。出来的洞啊很自然的。需要猫须的话调几...

我就是扫描下图得到了敬业福和爱国福

先来看下敬业福和爱国福 今年春节,支付宝再次推出了“五福红包”活动,表示要“把欠大家的敬业福都还给大家”。 今天该活动正式启动,和去年一样,需要收集“五福”...

冰箱异味产生的原因和臭味去除的方法

有时候我们打开冰箱就会闻到一股异味,冰箱里的这种异味是因为一些物质发出的气味的混合体,闻起来让人恶心。 产生这些异味的主要原因有以下几点。 1、很多人有这种习...

 
 
Ajax you HTML、JavaScript™ ji shu 、DHTML he DOM zu cheng , zhe yi jie chu de fang fa ke yi jiang ben zhuo de Web jie mian zhuan hua cheng jiao hu xing de Ajax ying yong cheng xu 。 dui yu Ajax, zui gai xin de yi ge dui xiang shi XMLHttpRequest, suo you de Ajax cao zuo dou li bu kai dui zhe ge dui xiang de cao zuo 。 shou xian wo men lai le jie zen me zai javascript zhong chuang jian zhe ge dui xiang : varxmlHttp=newXMLHttpRequest(); zhe xing jian dan de dai ma zai Mozilla、Firefox、Safari、Opera yi ji ji ben shang suo you yi ren he xing shi huo fang shi zhi chi Ajax de fei Microsoft liu lan qi zhong , chuang jian le XMLHttpRequest dui xiang 。 dan shi dui yu shi chang zhan you lv da dao 70% de IE lai shuo , zhe zhong fang fa shi bu xing de , er bu tong de IE ban ben huan you bu tong de chuang jian fang fa , suo yi wo men xu yao zai IE xia mian shi yong xia mian liang zhong chuang jian dui xiang de ban fa : try{ xmlHttp=newActiveXObject("Msxml2.XMLHTTP");// zhen dui jiao xin de liu lan qi }catch(err){ try{ xmlHttp=newActiveXObject("Microsoft.XMLHTTP");// zhen dui jiao lao de liu lan qi }catch(err2){ xmlHttp=false; } } ji shi zhe yang , wo men ye wu fa yu liao you xie liu lan qi ke neng wu fa chuang jian zhe ge dui xiang , suo yi zai chuang jian bu cheng gong de qing kuang xia , wo men huan yao jia shang yi ju : if(!xmlHttp){ alert(" wu fa chuang jian XMLHttpRequest dui xiang !"); } jie he qi lai jiu shi : varxmlHttp=false; try{ xmlHttp=newXMLHttpRequest(); }catch(trymicrosoft){ try{ xmlHttp=newActiveXObject("Msxml2.XMLHTTP"); }catch(othermicrosoft){ try{ xmlHttp=newActiveXObject("Microsoft.XMLHTTP"); }catch(failed){ xmlHttp=false; } } } if(!xmlHttp){ alert(" wu fa chuang jian XMLHttpRequest dui xiang !"); } ran hou , rang wo men jian li yi ge han shu getInfo(), da kai yi bu qing qiu : functiongetInfo(){ varnum=document.getElementById("num").value;// huo de biao dan de shu ju varurl="/ajax/1.php?n="+escape(num); xmlHttp.open("GET",url,true);// zhe li de true dai biao shi yi bu qing qiu } yi dan yong open() pei zhi hao zhi hou , jiu ke yi fa song qing qiu le 。 sui ran ke yi shi yong send() fa song shu ju , dan ye neng tong guo URL ben shen fa song shu ju 。 shi shi shang , zai da bu fen GET qing qiu zhong , yong URL fa song shu ju yao rong yi de duo , suo yi zhe li yong null zuo wei send() de shen shu jiu ke yi le 。url di zhi li mian de php wen jian shi bei qing qiu lai chu li suo xu yao shu ju de php wen jian , jiu xiang wo men ping shi yong PHP de shi hou yi yang , hou mian de shen shu ke yi jia duo ge , bing yong & fen ge kai lai 。 xmlHttp.send(null); zai fa song le shu ju zhi hou , wo men xu yao yong hui tiao fang fa lai huo de fu wu qi de zhuang tai , suo yi jiu yong dao le onreadystatechange shu xing 。 xmlHttp.onreadystatechange=updatePage; ci yu ju yi jing yao fang zai send() yu ju qian mian , zhe yang cai hui you xiao , hou mian de updatePage shi chu li fan hui xin xi de yi ge han shu 。 wan zheng de getInfo() ru xia : functiongetInfo(){ varnum=document.getElementById("num").value;// huo de biao dan de shu ju varurl="/ajax/1.php?n="+escape(num); xmlHttp.open("GET",url,true);// zhe li de true dai biao shi yi bu qing qiu xmlHttp.onreadystatechange=updatePage; xmlHttp.send(null); } wo men huan xu yao zai html li mian lai chu fa zhe ge han shu : <inputname="num"id="num"onblur="getInfo()"type="text"/> xia mian wo men xu yao lai bian xie updatePage() zhe ge han shu : functionupdatePage(){ if(xmlhttp.readyState==4){ varresponse=xmlhttp.responseText; document.getElementById("city").value=response; } } shang mian zhe duan dai ma li mian de readyState shi fu wu qi fan hui de yi ge zhuang tai ,4 zhe ge zhuang tai biao shi qing qiu yi jing fa song , bing chu li wan bi 。responseText shi huo de fu wu qi fan hui de xin xi , ran hou tong guo javascript fu gei ID wei city de biao dan 。 dao ci , yi ge jian dan de Ajax cheng xu jiu wan cheng le , wan zheng de javascript dai ma ru xia : varxmlHttp=false; try{ xmlHttp=newXMLHttpRequest(); }catch(trymicrosoft){ try{ xmlHttp=newActiveXObject("Msxml2.XMLHTTP"); }catch(othermicrosoft){ try{ xmlHttp=newActiveXObject("Microsoft.XMLHTTP"); }catch(failed){ xmlHttp=false; } } } if(!xmlHttp){ alert(" wu fa chuang jian XMLHttpRequest dui xiang !"); } functiongetInfo(){ varnum=document.getElementById("num").value;// huo de biao dan de shu ju varurl="/ajax/1.php?n="+escape(num); xmlHttp.open("GET",url,true);// zhe li de true dai biao shi yi bu qing qiu xmlHttp.onreadystatechange=updatePage; xmlHttp.send(null); } functionupdatePage(){ if(xmlhttp.readyState==4){ varresponse=xmlhttp.responseText; document.getElementById("city").value=response; } } zhe li huan que yi ge php wen jian , you yu chu li de fang shi bu yi yang , xie fa ye bu yi yang , er qie zhe bu shi Ajax de zhu yao bu fen , suo yi zhe li jiu bu fang dai ma le 。 zhi yao ji zhu php shi shu chu bing fan hui suo xu yao de shu ju jiu ke yi le hao jiu mei geng xin , jin tian kan dao zhe jiao cheng , dui chu xue zhe ting shi he .
󰈣󰈤
  免责声明:本文仅代表作者个人观点,与王朝网络无关。王朝网络登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
清凉一夏_清纯美丽
纯白色小礼服
靓丽可人儿_嘉嘉
我的女神_靓丽女生
主题摄影
贵州,让我欢喜,让我神伤。
莫干山
天平秋色
 
>>返回首页<<
 
 
 为你推荐
 
 
 
 转载本文
 UBB代码 HTML代码
复制到剪贴板...
 
 热帖排行
 
 
 
 
 
©2005- 王朝网络 版权所有