手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >jQuery中通过ajax的get()函数读取页面的方法
jQuery中通过ajax的get()函数读取页面的方法
摘要:首先介绍get()函数:url,[data],[callback],[type]参数说明:url:待载入页面的URL地址data:待发送Ke...

首先介绍get()函数:

url,[data],[callback],[type]

参数说明:

url:待载入页面的URL地址

data:待发送 Key/value 参数。

callback:载入成功时回调函数。

type:返回内容格式,xml, html, script, json, text, _default。

首先建立testGet.php实例:

<?php $web = $_GET['webname']; echo "你现在访问的网站是:".$web; ?>

然见建立ajax.html文件:

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>php点点通 - 关注php开发,提供专业web开发教程! </title> <script type="text/javascript" src="./jquery-1.7.1.min.js"></script> <script> $(document).ready(function(){ $("#btn").click(function(){ $.get("testGet.php",{web:"www.phpddt.com"},function(data,textStatus){ $("#result").append("data:"+data); $("#result").append("<br>textStatus:"+textStatus); }); }); }); </script> </head> <body> <input type="button" value="测试" id="btn" /> <h2>显示的内容如下:</h2> <div id="result"></div> </body> </html>

测试前的初始页面是:

jQuery中通过ajax的get()函数读取页面的方法1

点击测试后的结果是:

jQuery中通过ajax的get()函数读取页面的方法2

【jQuery中通过ajax的get()函数读取页面的方法】相关文章:

jQuery实现返回顶部效果的方法

jQuery计算文本框字数及限制文本框字数的方法

jQuery实现延迟跳转的方法

jQuery实现自动滚动到页面顶端的方法

jquery实现图片左右切换的方法

JavaScript中使用自然对数ln的方法

jQuery判断指定id的对象是否存在的方法

jQuery实现将页面上HTML标签换成另外标签的方法

jQuery实现转动随机数抽奖效果的方法

JQuery给网页更换皮肤的方法

精品推荐
分类导航