2.原始的Ajax的GET调用
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><script type="text/javascript">function createReq() {var req = false;if (window.XMLHttpRequest) { //Mozillareq = new XMLHttpRequest();} else if (window.ActiveXObject) { //IEtry { req = new ActiveXObject("Microsoft.XMLHTTP"); //IE6} catch (e) {try { req = new ActiveXObject("MsXML2.XMLHTP");} catch (e) {alert("创建XMLHttpRequest对象失败!");}}}return req;}window.onload = function() {var req = createReq();req.open("GET", "ajax_cont.cfm?id=1", true);req.onreadystatechange = function () {if (req.readyState == 4) {if (req.status == 200) {document.getElementById("test").innerHTML = req.responseText;}}}req.send(null); }</script></head><body><div id="test">Div Test</div></body></html>
页:
[1]