ajax post 同步异步问题

//新的评论
function sendCom(aId) {
    var currUrl = window.location;
    var liuyan = document.getElementById("liuyan");
    var txt = liuyan.outerHTML;
    if (txt == null || txt == "") {
        alert("回复内容不可以为空");
    } else {
        var check = checkLogin();
        if (check != "") //查看是否登录
        {
            $.ajax({
                type: 'get',
                url: "/user/AddCommentMsg",
                async: false,//当不写时,在火狐和谷歌下,只有当一步一步执行js时,才会留言成功,执行addcommentmsg,否则只是刷新页面。这就是异步同步的问题。
                  //当不写时,默认为 异步 async:true data: { comment: liuyan.innerHTML, aId: aId, cId:
null, currUrl: currUrl.href } }); window.location = currUrl.href.replace("#", ""); } else { alert("您还没有登录,请登录再评论"); } } }
posted @ 2012-10-24 10:46  南潇湘  阅读(520)  评论(0编辑  收藏  举报