type : "POST",
url : "user_do.jsp?optype=del&loginID="+loginID,      这种方式还是get传参吧。

解决方案 »

  1.   


    对这个是get传参方式,然后你在这里alert一下loginID是不是空,完了你在user_do.jsp页面看是怎么取值
    1,
    <%
    String loginID = request.getParameter("loginID");
    %>
    2,${param.loginID }
      

  2.   

    get还是一样的情况啊,大哥,全部代码如下
    <%@ page language="java"  pageEncoding="UTF-8"%>
    <%@include file="/common/dhtmlx-js.jsp"%> 
    <%
      response.setHeader("Cache-Control", "no-cache");
      response.setHeader("Pragma", "no-cache");
      response.setDateHeader("Expires", 0); 
     %>
     
     
    <html>
     <head>
     <title>用户管理</title>
     <script language="javascript" src="<%=basePath %>/js/lib/jquery.js"></script> </head>
        <script>
        var jq = jQuery.noConflict();
        var mygrid;
        var mymenu;      
        jq(document).ready(function() {
        mygrid = new dhtmlXGridObject('gridbox');
        mygrid.setImagePath("<%=basePath %>/ext/dhtmlx/dhtmlxGrid/imgs/");
        mygrid.setHeader("账号,密码,邮箱,手机");
        mygrid.setInitWidths("200,200,360,360");
        mygrid.setColAlign("center,center,center,center");
        mygrid.setColTypes("ro,ro,ro,ro");
        mygrid.setColSorting("str,str,str,str");
        mygrid.setSkin("dhx_skyblue");
        mygrid.init();
        
        
        mymenu = new dhtmlXToolbarObject("tab");
        mymenu.loadXML("tab.jsp?lb=toolbar",afterMenu);
        mymenu.setSkin('dhx_skyblue');    
        mymenu.attachEvent("onClick", function(id) {
         var xh = mygrid.getSelectedRowId();
        
         if(id == "new") {
        
         window.open("register.jsp","window","height=600,width=400");
         //window.location.href=window.location.href;
         }
        
        
         if(id == "del") {
        if (xh == "" || xh == null || xh == "null"){
        alert("请选择需删除的记录");     
        return;
        } else {
        mygrid.attachEvent("onRowSelect",function(id,ind) {
                
                loginID = mygrid.cells(id,0).getValue();
                alert(loginID);
                });
        
        doDel();
        
        
        }    
        
         }
        
        
         if(id == "edit") {
         doEdit(xh);
         }
        
        
         if(id == "view") {
         if (xh == "" || xh == null || xh == "null"){
        alert("请选择需查看的记录");
        return;
        }
         openModal("user_do.jsp?optype=view&xh="+xh,"window",800,410);
         }
        
         });
         });
         //加载数据
     </script>
      <body>
       <table cellpadding="0" cellspacing="0" width="100%" height="100%">
        <tr valign="top">
         <td>
          <div style="width:100%; height:100%;" id="gridbox"></div>
         </td>
        </tr>
        <tr height="26px">
         <td>     
          <div id="tab" style="height: 26px"></div>
         </td>
        </tr>
       </table>
      </body>
     <script>
    function afterMenu() {
      mygrid.loadXML("tab.jsp?lb!=toolbar");
    }


        function doEdit(rowId) {
         var xh = rowId;   if (xh == "" || xh == null || xh == "null") {
        alert("请选择需编辑的记录");
        return;
      }
        }    function doDel() {
       mygrid.attachEvent("onRowSelect",function(id,ind) {
                
               loginID = mygrid.cells(id,0).getValue();
               alert(loginID);
               });    
           var result = jq.ajax({
                 type : "POST",
                 url : "user_do.jsp?optype=del&loginID="+loginID,            
                 async : false
               }).responseText;
           result = trim(result);

           if (result == "ok") {
                  alert("删除成功!");
                  window.location.href = window.location.href;
              } else {
                   alert("删除失败");
              }
             }
        </script>
         
    </html>
      

  3.   

    jq.ajax如何使用,请参考jquery官方教程。
      

  4.   


    1、看看服务器的user_do.jsp这个url直接访问能通吗?//jsp在不在根目录?
    2、是只有loginID拿不到吗?//是不是参数名写错了?
    3、ajax,我这样写,仅供参考;function queryRegion(){
    var network= $("#network").val();
    $.ajax({
    type:"POST",
    url:"QueryIon",
    data:"network="+network,
    success:callback,
    error : function(data){
    alert("无法向服务器提交请求!");
    }
    });
    function callback(data){
    //alert("network_id ="+data);
    $("#result").html(data);
    }
    }
      

  5.   

    谢谢,一开始是我接受的参数写错了,然后自己发现了,现在已经改完了,也改成了这方法,不过我还是不知道该如何接收一个参数来显示成功还是失败。。            jq.ajax({
                 type : "POST",
                 data : "&loginID="+loginID,
                 url : "user_do.jsp?optype=del",            
                 async : false,
                 dataType : "json",
                 successs : function(data) {                  
                                if(){    
                                // view("修改成功!");     
                alert("删除成功!");    
                window.location.reload();    
                } else {    
                    
                }    
                },    
     error : function() {    
                    // view("异常!");     
                    alert("异常!");
                        
                }    
                 
               });这是jq.ajax,下面是uesr_do.jspif("del".equals(optype)) {
         request.setCharacterEncoding("UTF-8");
         String loginID = request.getParameter("loginID");      
         System.out.println("loginID="+loginID);   
         Connection con = DBcon.getCon();   
         Statement stmt = (Statement)con.createStatement();
         try {

        String sqlstring = "delete from T_LOGIN where LoginID = '"+loginID+"'";
        int a = stmt.executeUpdate(sqlstring);
        
        if(a>0)
        out.println("<script>alert('用户删除成功!')</script>");
            else
            out.println("<script>alert('用户不存在!'</script>"); 
      
         }
      

  6.   

    function queryRegion(){
        var network= $("#network").val();
        $.ajax({
            type:"POST",
            url:"QueryIon",
            data:"network="+network,
            success:callback,
            error : function(data){
                alert("无法向服务器提交请求!");
            }
        });
        function callback(data){
            //alert("network_id ="+data);
            $("#result").html(data);
        }
    }
    callback的参数data就是从jsp返回的值,也就是你out.println的内容; function callback(data){
            //alert("network_id ="+data);
            $("#result").html(data);
        }