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