当前位置: 代码迷 >> Java Web开发 >> struts2 jquery ajax提交表单,后台如何才能得到页面的值?代码如何写啊
  详细解决方案

struts2 jquery ajax提交表单,后台如何才能得到页面的值?代码如何写啊

热度:39   发布时间:2016-04-17 10:33:34.0
struts2 jquery ajax提交表单,后台怎么才能得到页面的值?代码怎么写啊?
JScript code
$(document).ready(function() {    var options = {        type : 'post',        dataType : 'json', //这个应该写什么类型?    }    $('#myform').submit(function() {        $(this).ajaxSubmit(options);        return false;    });});


HTML code
<form action="checkuser/test_login" id="myform" method="post"            namespace="/checkuser">            <table>                <tr>                    <td>                        <input type="text" id="user" ></br>                        <input type="text" id="pwd" ></br>                        <input type="submit" id="submitForm" value="submit_form" />                    </td>                </tr>            </table>        </form>


这样的提交,页面两个text的值是放到options里面了吗?怎么才能获得这些值? 手头没教材,百度没答案……不知道怎么写

------解决方案--------------------
$(document).ready(function() {
var user=$("#user").val();
var pwd=$("#pwd").val();
var options = {
type : 'post',
data : {'user':user,'pwd':pwd},
dataType : 'json', //这个应该写什么类型?
}
$('#myform').submit(function() {
$(this).ajaxSubmit(options);
return false;
});
});
这个是楼主想要的结果不?
  相关解决方案