ajax上传 data数据 后台接收为空

2024-12-22 00:03:37
推荐回答(2个)
回答1:

导入jQuery包

jQuery(document).ready(function($){
var url = "";
var data = {"param":"我是参数","other":"me too"};
$.post(url,data,function(result){
//.............
});
});

private String param;
private String other;
public void Test(){
PrintWriter out = null;
try{
out = getResponse().getWriter();
if(param.equals("我是参数")){
out.print(other);
}
}catch(Exception e){
//...
}finally{
out.flush();
out.close();
}
}

//getter and setter...

jQuery(document).ready(function($){
var url = "";
var data = {"param":"我是参数","other":"me too"};
$.post(url,data,function(result){
alert(result);
});
});

回答2:

导入jQuery包
1234567jQuery(document).ready(function($){ var url = ""; var data = {"param":"我是参数","other":"me too"}; $.post(url,data,function(result){ //............. });});