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

ajax交互只能运行一次
问题:点击按钮提交AJAX时,第一次可以运行,但是第二次就直接没有运行。
代码如下:
$.ajax({
                type: "GET",
                dataType: "JSON",
                url: "space.aspx?act=changestate&uid=" + uid + "&state=" + str,
                success: function(data) {
                var srr=eval("("+data+")");
                    if (srr.error> 0) {            
                        alert("出错了!");                       
                    }
                    else
                    {
                    alert("修改成功!");
                    if(str=="1")
                    {
                         document.getElementById("state1").checked=true;
                         document.getElementById("state2").checked=false;
                         }
                         else
                         {
                         document.getElementById("state2").checked=true;
                         document.getElementById("state1").checked=false;
                         }
                    }
                }
            });
解决办法:去掉缓存,
url="username.asp?username="+username + "&tm=" + new Date(),