jquery中怎样实现点击提交按钮把文本框的值提交到servlet

如题所述

$("button").click(function(){
$.ajax({
type: 'post', //post方式
async: false, //是否异步,默认为true
url: "/xxx/xxx", //发送的接收地址。
data: { "a": 1, "b": "2" }, //参数
error: function (xhr) { //如果发生错误,在这里处理或提示
},
success: function (str) { //如果成功,返回一个结果,在这里处理
},
dataType: "text" //返回结果的类型。

});

});
温馨提示:答案为网友推荐,仅供参考