代碼如下:
function load() { $.ajax({ type: "post", url: "WebForm3.aspx", data: "do=get", complete: function (msg) { show(msg.responseText)}, datatype:"html" }); } function show(strCode) { var start = strCode.indexOf("<select"); var end = strCode.indexOf("</select>") + 9; var strHtml = strCode.substring(start, end); //document.getElementById("myDiv").innerHTML = strHtml; var a = $("#myDiv")[0]; a.innerHTML = strHtml; //$("#myDiv").html(strHtml); $("#myDiv").dialog({ autoOpen: true, height: 500, width: 400, modal: true }); }
用了JUqeryUI中的dialog,對比用javascript是比較簡單些,還用到jquery對象向Dom對象轉換
function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("myDiv").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET", "HTMLPage1.htm?fname=Bill&lname=Gates", true); xmlhttp.send(); }
參考的文章有:
http://hi.baidu.com/why_8645/blog/item/293a535547a67c50d009066f.html