ajax獲取后端數(shù)據(jù) ajax獲取數(shù)據(jù)之后怎么替換整個頁面內(nèi)容?
ajax獲取數(shù)據(jù)之后怎么替換整個頁面內(nèi)容?假設頁面a的內(nèi)容如下:<body><div id=“test”></div>JS,使用Ajax獲取數(shù)據(jù)后的具體操作:$。Ajax({t
ajax獲取數(shù)據(jù)之后怎么替換整個頁面內(nèi)容?
假設頁面a的內(nèi)容如下:
<body>
<div id=“test”></div>
JS,使用Ajax獲取數(shù)據(jù)后的具體操作:
$。Ajax({
type:“post”,
URL:“URL of data request”,
data:要傳遞的參數(shù)成功:功能(result){
//成功獲取數(shù)據(jù)
if()]{
var s=“<div>需要替換的特定內(nèi)容是以串聯(lián)字符串的形式。。。</div>“
$(“#test”)??眨ǎ?/p>
$(“#test”)。追加
}
!]{
//數(shù)據(jù)請求失敗的交互提示;
}
]})