ITeye博客

jquery中页面Ajax方法$.load的功能

adsen · 2014-10-17 22:06 · Web前端 · Markdown

load语法

$(".selector").load("url", function(responseText, statusText, xmlhttprequest));

可以做到加载一个页面的时候,如果发生错误,根据statusText给出的状态,显示对应的提示,这对用户来说非常重要。

例子,load post

代码如下 复制代码

$("#btnAjaxPost").click(function(event) { var username = $("#username").val(); //发送Post请求 $("#divResult").load("$(www.111cn.net){ctx}/jqueryLoad", { "username": username}); });

例子,load get方法

代码如下 复制代码

Ajax方法$.load乱码

一般引起load乱码是由于二者页面编码不致影起的,处理方法是

1.我的显示页面index.html的编码是uft-8的; 2.我的静态页面foot.html的编码是uft-8的;

$("#index_foot_container").load("foot.html"); from:http://www.111cn.net/wy/jquery/67792.htm

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。