日期:2014-05-17  浏览次数:20693 次

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;
});
});
这个是楼主想要的结果不?