加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Ajax

发布时间:2020-12-15 22:05:42 所属栏目:百科 来源:网络整理
导读:方式一: script type="text/javascript" src="./js/jquery-1.4.2.min.js"/script script type="text/javascript" function hqwhf(){ $.ajax( { url : "teacher.do", type : "GET", data :"method=nothuifutf", dataType : "html", cache : false, timeout :

方式一:

<script type="text/javascript" src="./js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
function hqwhf(){
$.ajax( {
url : "teacher.do",
type : "GET",
data :"method=nothuifutf",
dataType : "html",
cache : false,
timeout : 0,

//error : function() {
//alert('Error loading XML document');
//},
success : function(html) {
$("#test" ).html(html);
}
});
var o = document.getElementById("pop");

o.style.display = "";
}
</script>

方式二:

<script type="text/javascript" src="./js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
function hqwhf(){
$.ajax( {
type : "POST",
url : "teacher.do?method=nothuifutf",
success : function(data) {
$("#test" ).html(data);
}
});
var o = document.getElementById("pop");

o.style.display = "";
}
</script>

说明:

方式二来源于:

<script type="text/javascript" src="./js/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
//加载地区的下拉列表
function cityOption(obj,type) {
var pId = obj.value;
$.ajax({
type : "POST",
url : "/article/findPlace?proId=" + pId + "&type=" + type,
success : function(data) {
if (type == 2)
$("#city_td").html(data);
if (type == 3)
$("#area_td").html(data);
}
});
}
</script>

比较:

一个get,一个post,你说哪一个好呢.

尽量用post提交,get提交地址栏上长度有限制,而且不安全.

get传中文也可以,但是必须转码才行

火狐会不兼容,写上dataType就OK了

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读