桃花长相依
所context要做的就是this在回调中设置的值。因此,如果您在事件处理程序中,并且希望this在回调中将其作为接收事件的元素,则可以这样做:context:this,success:function() { // "this" is whatever the value was where this ajax call was made}如果您希望将其设置为其他类型,则只需进行设置即可,并this引用该类型:context:{some:'value'},success:function() { // "this" the object you passed alert( this.some ); // "value"}在添加到问题中的代码中,可以使用StateID,但实际上并不需要,因为您已经可以访问该变量。var StateID = $(this).parents('tr').attr('id');$.ajax({ url: 'Remote/State.cfc' ,data: { method:'Delete' ,'StateID':StateID } ,context: StateID ,success: function(result){ alert(this); // the value of StateID alert(StateID); // same as above if (result.MSG == '') { $('#' + result.STATEID).remove(); } else { $('#msg').text(result.MSG).addClass('err');; }; }});