日期:2014-05-16  浏览次数:20589 次

关于JQuery ajax的post方式的问题
本帖最后由 showbo 于 2013-05-16 11:59:36 编辑
我的代码如下,但是却提交不了数据,各位大神帮忙看一下吧

$(function () {
            var str="";
            $("#tijiao").click(function () {
                $.ajax({
                    type: "post",
                    contentType: "application/json",
                    url: "shiyan.aspx",
                    data: {
                        username: $("#txt1").val(), password: $("#txt2").val()
                    },
                    success: function (data) {
                            for (var i = 0; i < data.length; i++) {
                                str += "<tr><td>" + data[i].firstName + "</td>" + "<td>" + data[i].lastName + "</td></tr>";
                            }
                            $("tbody").html(str);
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(errorThrown);
                    }
                })
            });
        })