启用使用AjAx和post方法将数据发送到servlet的功能 [英] Enable to send data to servlet using AjAx and post method

查看:183
本文介绍了启用使用AjAx和post方法将数据发送到servlet的功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

这是我的代码.这有什么问题吗?任何类型的语法或语义错误.
问题:无法通过URL将参数发送到servlet.?????

This is my Code. Is something wrong with it?? Any kind of syntax or semantics error.
Problem:Not able to send parameter to servlet in URL.?????

推荐答案

如果希望Servlet的doPost方法处理请求,则应添加值为post的属性type.

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");
        }
    });
}

这样,您的Ajax请求将被发送,而不是get(默认请求).

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

这篇关于启用使用AjAx和post方法将数据发送到servlet的功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆