使用 ajax 提交数据

xiaoxiao2022-06-14  71

 

 

 

<!--<br /><br />Code highlighting produced by Actipro CodeHighlighter (freeware)<br />http://www.CodeHighlighter.com/<br /><br />--> 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.

相关资源:敏捷开发V1.0.pptx
转载请注明原文地址: https://www.6miu.com/read-4936641.html

最新回复(0)