jquery中页面Ajax方法$.load的功能使用介绍

前端之家收集整理的这篇文章主要介绍了jquery中页面Ajax方法$.load的功能使用介绍前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

load语法

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

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

例子,load post

代码如下

代码如下:
点击我
内容加载中

$("#btnAjaxPost").click(function(event) { var username = $("#username").val(); //发送Post请求 $("#divResult").load("$(www.jb51.cc){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");

原文链接:https://www.f2er.com/ajax/57490.html

猜你在找的Ajax相关文章