2016-cxp
$(# id).click(funtion(){
$.ajax{
type:"post",
data:{name: $(#id) .val() },
async:"true",//默认 异步提交
traditional:true, //表示传递的是数组
dataType:"text",//预期服务器返回的数据类型 String,text,json,xml,html,script,
contentType: 类型:String 默认值: "application/x-www-form-urlencoded"。发送 信息至服务器时内容编码类型
success:function(data){
if(data.success){
.........................
return true;
}else{
............................
return true;
}
}
}
})
 
注:
  1:ajax 前台用traditional:true,后台使用springmvc 时参数这样写,可得到数据
    @RequestParam("test") Integer[] test
  2:dataType:"json", 返回的是json 对象,若是没有定义dataType,success:function(date){ }date 是json字符串,不是json对象
  json字符串转json对象。var jsonObj = $.parseJSON(date);
 
 
 
 
 
 
 
 

分类:

技术点:

相关文章:

  • 2021-08-29
  • 2022-12-23
  • 2021-12-04
  • 2021-10-24
  • 2021-11-07
  • 2021-12-26
猜你喜欢
  • 2021-12-09
  • 2021-10-04
  • 2021-08-05
  • 2021-09-29
  • 2022-01-01
  • 2021-09-23
  • 2021-09-18
相关资源
相似解决方案