JS異步請求數據


 

不刷新頁面,不需要Jquery等等

 

JS代碼

var http =  new ActiveXObject("Microsoft.XMLHTTP");
http.open("Get","demo.do?status=c&name="+name, false);
http.send();
alert(http.responseText);

 Java代碼

public  class DemoAction
     extends DispatchAction {

      public ActionForward c(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response)  throws Exception {
     String name=  new String(request.getParameter("name").getBytes("ISO-8859-1"), "gbk");

    request.setAttribute("ch","aaa");
     return (mapping.findForward("ch"));
  }
}
 
struts.xml
  <action type="com.DemoAction" parameter="status" path="/demo" >
    <forward name="ch" path="/ch.jsp" />
  </action>

 

ch.jsp代碼

<%@ page contentType="text/html; charset=gb2312" language="java"  import="java.sql.*" errorPage="" %><%String ch=(String)request.getAttribute("ch");

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM