load語法
$(".selector").load("url", function(responseText, statusText, xmlhttprequest));
可以做到加載一個(gè)頁面的時(shí)候,如果發(fā)生錯(cuò)誤,根據(jù)statusText給出的狀態(tài),顯示對(duì)應(yīng)的提示,這對(duì)用戶來說非常重要。
例子,load post
代碼如下
$("#btnAjaxPost").click(function(event)
{
var username = $("#username").val();
//發(fā)送Post請(qǐng)求
$("#divResult").load("$(www.survivalescaperooms.com){ctx}/jqueryLoad", { "username": username});
});
代碼如下
一般引起load亂碼是由于二者頁面編碼不致影起的,處理方法是
1.我的顯示頁面index.html的編碼是uft-8的;
2.我的靜態(tài)頁面foot.html的編碼是uft-8的;
$("#index_foot_container").load("foot.html");
|
新聞熱點(diǎn)
疑難解答
圖片精選