3 回答

TA貢獻1998條經驗 獲得超6個贊
如果你使用ajax請求后發生了你說的情況(原來的內容不見了),就說明你并沒有學會如何使用ajax,給你個最簡單的例子:
a.aspx
<div>其它內容</div>
<div id="d1">這里的內容準備用ajax獲取</div>
<script>
var req = new ActiveXObject("MSXML2.XMLHTTP")||window.createRequest()||new XMLHttpRequest();
req.open("get","a.aspx?getc=1",true);
req.onreadystatechange=function(){
if(req.readyState==4)document.getElementById("d1").innerHTML=req.responseText;
};
req.send(null);
</script>
a.aspx.cs
page_load
{
if(Reqest["getc"]!=null){
Repsonse.Write("輸出ajax請求的內容");
Response.End();
}
}

TA貢獻1802條經驗 獲得超5個贊
$.getJSON('/your/url', {param1: value1, param2: value2}, function(data) {
console.log(data);
});
建議使用 FireBug 調試,先看看到具體返回什么內容。
- 3 回答
- 0 關注
- 108 瀏覽
添加回答
舉報