我用的是1.41,想要实现注销功能,注销为登陆后动态添加的一个a标签
代码如下:$("a[href$='logout.asp']").click(function(event) {
           event.preventDefault();
         $.get("/xxlr/Logout.asp","",function(data, textStatus) {
             if (data == 1) {  //表明注销成功
                 $('#message').html("");
                 $("#userlogin>div").show(); 
             }
             else {
                 $('#message').append("<p><strong>注销失败,请重新尝试!</strong></p>");
             }
         });
     });     
现在点击注销后,只能显示输出1

解决方案 »

  1.   


    if (data == 1) {  //表明注销成功
                            $('#message').html("");
                            $("#userlogin>div").show(); 
                            return;//这里应该加上,因为不需要继续向下执行
                        }
      

  2.   

    问题已经找到,是因为注销 a标签是动态创建,$("a[href$='logout.asp']")找不到,我换成$("a[href$='xx.asp']")页面上存在的一个连接a标签,就可以执行服务器端asp成功后响应输出
    response.write "<p><strong>"&session("lr_ucode")&"</strong>:欢迎回来![<a href='/xxlr/Logout.asp'>注销</a>]</p>"//客户端post,回调成功的函数,接收服务器端的输出
    function (data,textStatus) {
               if (data != 0) {
                    $("#userlogin>div").hide();
                    $('#message').attr("class","welcome").append(data);
          }问题一,服务器端输出到页面的响应是乱码?
    问题二,如何给$("a[href$='logout.asp']")绑定事件?
      

  3.   

    乱码原因比较多,看看编码是否一致....绑定事件可以
    $("a[href$='logout.asp']").bind("onclick",function(){...});
    绑定onclick或者其他事件....
      

  4.   

    我所说的绑定,是如何找到$("a[href$='logout.asp']"),前面的代码没有执行,是因为找不到$("a[href$='logout.asp']"),因为它是由下面的jquery语句动态创建,  //回调函数收到数据响应输出data,data为(<p><strong>"&session("lr_ucode")&"</strong>:欢迎回来![<a href='/xxlr/Logout.asp'>注销</a>]</p>)
       $('#message').attr("class","welcome").append(data); 我感觉应该在这句后绑定,代码才能生效 
       $('#message').attr("class","welcome").append(data).(xxxxx);
      

  5.   

    你说那个<a>标签 是动态创建 的 那你在创建时 直接绑定 <a onclick='funName(this)'>,这里的this不就代表了这个<a>么 是这个意思吧?