Ajax同步与异步传输的示例代码
2013-11-21 00:00
651 查看
//同步传输模式 function RequestByGet(nProducttemp,nCountrytemp) { var xmlhttp if (window.XMLHttpRequest) { //isIE = false; xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { //isIE = true; xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } //Web page location. var URL="http://www.jb51.net/; xmlhttp.open("GET",URL, false); //xmlhttp.SetRequestHeader("Content-Type","text/html; charset=Shift_JIS") xmlhttp.send(null); var result = xmlhttp.status; //OK if(result==200) { document.getElementById("div_RightBarBody").innerHTML=xmlhttp.responseText; } xmlhttp = null; } //异步传输模式 var xmlhttp function RequestByGet(nProducttemp,nCountrytemp) { if (window.XMLHttpRequest) { //isIE = false; xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { //isIE = true; xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } //Web page location. var URL="http://www.jb51.net/"; xmlhttp.open("GET",URL, true); xmlhttp.onreadystatechange = handleResponse; //xmlhttp.SetRequestHeader("Content-Type","text/html; charset=UTF-8") xmlhttp.send(null); } function handleResponse() { if(xmlhttp.readyState == 4 && xmlhttp.status==200) { document.getElementById("div_RightBarBody").innerHTML=xmlhttp.responseText; xmlhttp = null; } }
相关文章推荐
- Ajax同步与异步传输的示例代码
- Ajax实现的异步传输与验证示例代码
- Ajax实现的异步传输与验证示例代码
- 异步(ajax)动态加载无限级联树(tree)代码示例
- ajax异步处理POST表单中的数据示例代码
- ext 同步和异步示例代码
- 图片上传,支持同步/异步、预览(MVC、uploadify异步提交、js预览、ajaxSubmit异步提交)兼容大部分浏览器,含代码
- Ajax同步和异步传输
- ext 同步和异步示例代码
- jquery的ajax同步和异步的理解及示例
- 由Ajax对比同步传输和异步传输
- Thinkphp结合ajaxFileUpload实现异步图片传输示例
- jquery的ajax同步和异步的理解及示例
- jquery的ajax同步和异步的理解及示例
- Ajax异步传输与PHP实现交互示例
- AJAXPro用法,关于JS同步和异步调用后台代码的学习
- jquery的ajax同步和异步的理解及示例
- jquery ajax 同步异步的执行示例代码