以下代码有什么错误?

时间:2013-09-16 11:19:33

标签: javascript php jquery html

我正在为我的网站使用PHP,jQuery,Colorbox-ajQuery灯箱插件等。我不知道错误来了!你能帮我这方面吗?  我的代码如下:

<span class="submit edit_user_transaction_status" value="{$control_url}{$query_path}?op=edit_user_transaction&page={$page}&txn_no={$user_transaction_details.transaction_no}&transaction_data_assign={$user_transaction_details.transaction_data_assign}&user_id={$user_id}{if $user_name!=''}&user_name={$user_name}{/if}{if $user_email_id!=''}&user_email_id={$user_email_id}{/if}{if $user_group!=''}&user_group={$user_group}&{/if}{if $user_sub_group!=''}&user_sub_group={$user_sub_group}{/if}{if $from_date!=''}&from_date={$from_date}{/if}{if $to_date!=''}&to_date={$to_date}{/if}{if $transaction_status!=''}&transaction_status={$transaction_status}{/if}{if $transaction_no!=''}&transaction_no={$transaction_no}{/if}">Update</span>

$(document).ready(function() {
$(".edit_user_transaction_status").live('click', function(e) { alert("Hallo");
      e.preventDefault();

        $.colorbox.close();

         //for confirmation that status change
         var ans=confirm("Are you sure to change status?");
         if(!ans) {
             return false;
         }  
         var post_url           = $(this).attr('value');
         var transaction_status_update = $('#transaction_status_update').val();      

         $.ajax({
             type: "POST",
             url: post_url+"&transaction_status_update="+transaction_status_update,
                 data:$('#transaction_form').serialize(),
             dataType: 'json',  
             success: function(data) {              
                 var error = data.login_error;

                 $(".ui-widget-content").dialog("close");
                //This variables use for display title and success massage of transaction update              
                 var dialog_title   = data.title;              
                 var dialog_message = data.success_massage; 
                 //This get link where want to rerdirect
                 var redirect_link  = data.href;            

                 var $dialog = $("<div class='ui-state-success'></div>")
                 .html("<p class='ui-state-error-success'>"+dialog_message+"</p>")
                 .dialog({
                     autoOpen: false,
                     modal:true,
                     title: dialog_title,
                     width: 500,
                     height: 80,
                     close: function(){                                     
                         document.location.href =redirect_link;
                     }                  
                 });                    

                 $dialog.dialog('open');                    
             }          
        });
     });
});

点击更新范围后,我在控制台中收到以下错误:

TypeError: $(...).live is not a function
[Break On This Error]   

$(".edit_user_transaction_status").live('click', function(e) { alert("Hallo");

你能告诉我为什么会出现这个错误,这个问题的解决方案是什么?提前谢谢。

2 个答案:

答案 0 :(得分:0)

Live在1.9+中删除,在1.7+中使用on()弃用,如果该元素是动态添加委托在最近的静态元素上

$(document).on('click', '.edit_user_transaction_status', function (e) {
    alert("hallo")
});

答案 1 :(得分:0)

我无法发表评论,因为我的声誉很低,但这应该有效

$(".edit_user_transaction_status").on('click', function (e) {
    alert("hallo")
});