有效Ajax案例

<script>
$(document).ready(function(){ $("input:submit").click(function(){ $.ajax({ type: "POST", url: "Ajax", contentType: ‘application/x-www-form-urlencoded;charset=utf-8‘, data: {name:$("#username").val(), pwd:$("#password").val()}, dataType: "html", success: function(data,status){ alert("数据: \n" + data + "\n状态: " + status); }, error:function(data,status){ alert("数据: \n" + data + "\n状态: " + status); }, }); }); });
</script>



function commit(){
    $.ajax({
        type: ‘GET‘,
        // dataType: ‘json‘,
        async: true,
        url: "editArticleSubmit1",
        data: {
            name:$("#name").val(),
            sex:$("#sex").val(),
            age:$("#age").val(),
            purpose:$("#purpose").val(),
            workAge:$("#workAge").val(),
            content:$("#content").val(),
        },
        success: function (data) {
            // obj=eval(‘(‘+obj+‘)‘);//这段代码就是将字符串转换成json格式

            /*var name = this.data.name;
            var sex = this.data.sex;
            var age = this.data.age;
            var purpose = this.data.purpose;
            var workAge = this.data.workAge;
            var content = this.data.content;*/

            alert("投递成功");
        }, error: function (msg,status) {
            alert(msg+status);
            return;
        }
    });
    // var a=$("#massage").val();
    // alert(a)
}

 

$(document).ready(function(){$("input:submit").click(function(){$.ajax({    type: "POST",    url: "Ajax",    contentType: ‘application/x-www-form-urlencoded;charset=utf-8‘,    data: {name:$("#username").val(), pwd:$("#password").val()},    dataType: "html",    success: function(data,status){    alert("数据: \n" + data + "\n状态: " + status);             },    error:function(data,status){    alert("数据: \n" + data + "\n状态: " + status);    },             });});});

有效Ajax案例

上一篇:Java Timer及TimerTarsk(摘自网络)


下一篇:js常用方法