Blogger Information
Blog 35
fans 0
comment 1
visits 42686
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
jquery的load()的方法使用
魏先生的博客
Original
1525 people have browsed it

首先肯定是2个文件,放到'www'目录下G{7(T(DSG`E$]GAH1MTK`$7.png

load()方法为局部方法,也是ajax的唯一的局部方法.

实例1: 默认

load页面:
<input type="button" name="" id="" value="点击提交" />
		<div></div>
<script type="text/javascript">
       $(function(){
                $('input').click(function(){
                    $('div').load('url.html .sub-title1');
                });
         })
</script>


url页面:
<span class="title1">我是title1</span>
<span class="title2">我是title2</span>

运行实例 »

点击 "运行实例" 按钮查看在线实例

load里面的参数是url.html 就是要获取的url.   后面的sub-title1为一个类,这个类是指定获取的类.

实例2 GET

load页面:
<input type="button" name="" id="" value="点击提交" />
		<div></div>
		<script type="text/javascript">
			$(function(){
				$('input').click(function(){      //get方式提交  默认也是get方式
					$('div').load("url.php?url=ku");
				})
			})
		</script>
		
url页面:
if($_GET['url']=='ku'){
  echo 'GET提交成功';
}else{
  echo '失败';
}			

运行实例 »

点击 "运行实例" 按钮查看在线实例

给get加了条件,条件允许才会提交成功;


实例3 POST

load页面:
<input type="button" name="" id="" value="点击提交" />
		<div></div>
		<script type="text/javascript">
			$(function(){
				$('input').click(function(){      //POST方法,要传送的地址栏也要用POST接收
					$('div').load("url.php",{
						url:'ku'
					});
				})
			})
		</script>
		
url页面:
if($_POST['url']=='ku'){
echo 'POST方式提交';
}else{
echo '无法完成';
}		

运行实例 »

点击 "运行实例" 按钮查看在线实例

$_POST方法 url地址后面直接跟对象{  url:'ku'  };

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post