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

ajax方法的用法

发布时间:2020-12-16 03:34:50 所属栏目:百科 来源:网络整理
导读:$.ajax({ type : "POST" ,url : "test.do" ,data : text,async : false,dataType : "json" ,success : function(res) { aler("test"); },error : function(res) { },complete : function() { }}); dataType : "json" , 服务器端返回的数据格式 json格式 也可
$.ajax({
   type : "POST",url : "test.do",data : text,async : false,dataType : "json",success : function(res) {
     aler("test");
    
   },error : function(res) {
    
   },complete : function() {
   }
});
dataType : "json",
服务器端返回的数据格式  json格式  也可以是text等类型
 async : false   默认是true       false  表示为同步 什么意思呢?  意思就是要等test.do 完成后才会执行
                                  aler("test");这个操作  如果为true 的话就是还没执行完test.do  就执行
                                  aler("test"); 但是这个地方就说报错 因为没有返回值 或者说test.do执行出错了依然会执行

在test.do后面可以放通过以下方式存放数据:  
1:"${context_root}/bmbucbp1/bui570002.do?&cop_bus_typ="
      + cop_bus_typ+"&old_jrn_no="+old_jrn_no+"&old_ord_no="+old_ord_no,
2: 在data 里面放json格式的数据 data:{"applyNumber":applyNumber},

3:text= "&cop_bus_typ="+cop_bus_typ
data:text

4:var params = $("#addform1").serialize(); // http request parameters. 
jQuery的serialize()方法通过序列化表单值data:params
contentType 发往服务器的格式 默认是 "application/x-www-form-urlencoded"dataType是服务器端返回数据格式http://cnn237111.blog.51cto.com/2359144/984466

(编辑:李大同)

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

    推荐文章
      热点阅读