手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jquery中页面Ajax方法$.load的功能使用介绍
jquery中页面Ajax方法$.load的功能使用介绍
摘要:load语法$(".selector").load("url",function(responseText,statusText,xmlht...

load语法

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

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

例子,load post

代码如下

复制代码 代码如下:

<div id=btnAjaxPost>点击我</div>

<div id=divResult>内容加载中</div>

$("#btnAjaxPost").click(function(event)

{

var username = $("#username").val();

//发送Post请求

$("#divResult").load("$(www.jb51.net){ctx}/jqueryLoad", { "username": username});

});

例子,load get方法

代码如下

复制代码 代码如下:

<div id=in_head>内容加载中</head>

<script language="javascript">$('#in_head').load('ajaxlogin.php?cityid=1208');</script>

Ajax方法$.load乱码

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

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

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

$("#index_foot_container").load("foot.html");

【jquery中页面Ajax方法$.load的功能使用介绍】相关文章:

浅谈JavaScript中的Math.atan()方法的使用

JavaScript中的unshift()方法的使用

JavaScript中Cookies的相关使用教程

详解JavaScript中Date.UTC()方法的使用

javascript中FOREACH数组方法使用示例

JavaScript中setMonth()方法的使用详解

JavaScript中的sub()方法的使用介绍

简介JavaScript中charAt()方法的使用

AngularJS 最常用的功能汇总

jQuery获取页面元素绝对与相对位置的方法

精品推荐
分类导航