谁能告诉我为什么我的代码:$(this).parent().hide();
当放置在我的.post()
喜欢之外时有效(所选的 div 被隐藏):
$(document).on('submit', '.reply-message-form', function(e) {
$(this).parent().hide();
if($(this).children('.post-reply-message-textarea').val() == '')
return false;
$.post("<?php echo Yii::app()->createUrl('event/view', array('id'=>Yii::app()->controller->actionParams['id'])); ?>",
$(this).serialize(), function(response) {
var responseObject = jQuery.parseJSON(response);
// if successful.. process..
if (responseObject.success == true) {
} else {
alert('failed');
}
});
return false;
}) ;
但是,如果将.hide()
其放入成功函数中,则.post()
不会发生任何事情..?!里面的代码:
$(document).on('submit', '.reply-message-form', function(e) {
if($(this).children('.post-reply-message-textarea').val() == '')
return false;
$.post("<?php echo Yii::app()->createUrl('event/view', array('id'=>Yii::app()->controller->actionParams['id'])); ?>",
$(this).serialize(), function(response) {
$(this).parent().hide();
return false;
var responseObject = jQuery.parseJSON(response);
// if successful.. process..
if (responseObject.success == true) {
} else {
alert('failed');
}
});
return false;
}) ;
只是为了清除任何疑问- responseObject.success 确实 == true (我已经通过警报等确认了这一点)。
提前致谢!