主要记录下jq,ajax赋值给外部变量

一、ajax获取的值赋值给外部变量
$('button').click(function(){
  var list;
  
  $.ajax({
  type: 'POST',
  async: false, //改成同步就可以把ajax获取的值赋值给外部变量
  url: '/edit', //与edit相同都是得到对应code的success_detail
  data: JSON.stringify(code),//将对象打包成json的字符串发送,对应后面也要将字符串解码成字典
  contentType: 'application/json;charset=UTF-8',//编码格式
  dataType: 'json',
  success: function (data) {
   list = data['list'];
  }

  });
})
二、通过多class获取元素
例如:<div class="as df gh"></div>
$('.as.df.gh')//注意没有空格

猜你喜欢

转载自www.cnblogs.com/bwcheng/p/11978680.html