惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
I
InfoQ
C
Check Point Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
Last Week in AI
Last Week in AI
GbyAI
GbyAI
P
Proofpoint News Feed
量子位
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
B
Blog
T
The Blog of Author Tim Ferriss
H
Help Net Security
云风的 BLOG
云风的 BLOG

博客园 - 笑笑江南

sss IBATIS 延迟加载 iBATIS一对多/多对多N+1问题解决方案 - 笑笑江南 - 博客园 [转]office outlook 2007 如何设置开机自动启动 代码整洁之道 类关系 eclipse 快捷键 9-15 企业数据更新 mysql 常用函数 利用myeclipse生成Hibernate Mapping文件【转】 配置eclipse下tomcat启动参数【转】 安装svneclipse .net 开发相关工具(包)的作用 basicform 与 store gridpanel中拖拽排序 struts2 file 标签产生的一个问题 applyTo ,render, contentel,el,applytomarkup 的区别 呕吐呕吐 tabpanel 添加 tab
使用 ajax 提交数据
笑笑江南 · 2008-11-30 · via 博客园 - 笑笑江南

var Ajax = {

    xmlHttp:

"",
    getYear:
function(){
      
return  document.getElementById("SY").selectedIndex+1900+"";
    },
    getMonth: 
function (){
      
return  document.getElementById("SM").selectedIndex+1+"";
    },
 createXMLHttpRequest:
function () {
      
if (window.ActiveXObject) {
          xmlHttp 
= new ActiveXObject("Microsoft.XMLHTTP");
      }
      
else if (window.XMLHttpRequest) {
          xmlHttp 
= new XMLHttpRequest();
      }
 },
 send:
function () {
   
this.createXMLHttpRequest();
   xmlHttp.onreadystatechange 
= this.showResponse;
   xmlHttp.open(
"POST""DateSetAjax.action?toShowYearMonth="+ leftPad(this.getYear ())+"-"+leftPad(this.getMonth()), false);
   xmlHttp.send(
"yearmonth=aa");
 },
 showResponse:
function(){
    
if(xmlHttp.readyState == 4) {
      
if(xmlHttp.status == 200) {  
       
var data =  xmlHttp.responseText;
       
if(data=="null")
         data 
= "";
       CLD.date1.value
=data;
    }
   }
 }

}

Ajax.send(); 发送请求。

 上面代码 参数必须在附在url 后面 才能在struts2中取到。xmlHttp.send("yearmonth=aa"); 中的参数并不起作用。

send 怎么发送数据呢

ServletActionContext.getRequest().getParameter(key); ok

ActionContext.getContext().get("request").get(key);  null.