0
function validate (user_value){
    var name = user_value;
    $.ajax({
        url:"ggs.erm.servlet.setup5.AjaxS",
        data:{ namee :name},
        success:function(){
            alert("worked");
        }
    });
}

这是我的代码。是不是有什么问题??任何类型的语法或语义错误。
问题:无法在 URL 中向 servlet 发送参数。??????

4

2 回答 2

1

If you want your servlet's doPost method to handle the request you should add property type with value post.

function validate (user_value){
    var name = user_value;
    $.ajax({
        url:"ggs.erm.servlet.setup5.AjaxS",
        data:{ namee :name},
        type: 'post',
        success:function(){
            alert("worked");
        }
    });
}

This way your Ajax request will be post instead of get (the default one).

于 2013-01-24T10:21:54.363 回答
0

看来您的函数在doc ready处理程序中检查一下,看看是否有帮助:

 function validate (user_value){
    var name = user_value;
    $.ajax({
       url:"ggs.erm.servlet.setup5.AjaxS",
       type:'POST', //<-----------------added this
       data:{ namee :name},
       success:function(data){
         if(data){
          alert("worked");
         }
       },
       error:function(){
         alert('not worked.');
       } 
    });
}

$(document).ready(function(){
   // your other code stuff for calling the function
});
于 2013-01-24T10:39:04.333 回答