日期:2014-05-16  浏览次数:20736 次

extjs不能发送ajax请求,本人新手,求大神指点,代码如下。
本帖最后由 showbo 于 2013-05-27 13:50:52 编辑
html代码
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>lo.html</title>

    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="this is my page">
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
    <link rel="stylesheet" type="text/css" href="extjs/resources/css/ext-all.css">
<script type="text/javascript"src="extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="extjs/ext-all.js"></script>
<script type="text/javascript" charset="gbk" src="ceshi.js"></script>

  </head>
  
  <body>
  用户名: <input type="text" id="uname" >
  密码:<input type="text" id="upass">
  <input type="button" value="提交" id="tj">
  </body>
</html>


js代码。。。
/**
 * 
 */
Ext.onReady(function(){
alert("ok");

Ext.get('tj').on("click",function(){
/*alert("ok");*/

Ext.Ajax.request({

url:"http://127.0.0.1:8080/ext/hello",
method:'POST',
params:{
uname:Ext.getDom('uname').value,
upass:Ext.getDom('upass').value
},
success:function(resp){
alert(resp.responseText);
}
});




});


});


servelet代码:

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


public class hello extends HttpServlet {

/**
 * Constructor of the object.
 */
public hello() {
super();
}

/**
 * Destruction of the servlet. <br>
 */
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}

/**
 * The doGet method of the servlet. <br>
 *
 * This method is called when a form has its tag value method equals to get.
 * 
 * @param request the request send by the client to the server
 * @param response the response send by the server to the client
 * @throws ServletException if an error occurred
 * @throws IOException if an error occurred
 */