嗨我有关于php symfony delete.my的问题javascript和ajax邮政编码很好。我不知道为什么它不能删除到我的数据库。我已经定位并传递了id,而且我已经设置了我的routing.yml。我继续调试这个,但什么都没发生。 这是前端模块研讨会
<script type="text/javascript">
$(document).ready(function(){
$(".tbl_comments").show();
//$("#loading").hide();
$("#ptxt_green").hide();
$('#comment_form').ajaxForm({
target: '.tbl_comments',
beforeSubmit: validate,
success: function(){
//alert(data);
$(".tbl_comments").fadeIn('slow');
}
});
$("#loading")
.hide()
$(".tbl_comments").show()
.ajaxStart(function(){
$(this).show();
$(".tbl_comments").hide();
$("#loading").show();
})
.ajaxStop(function(){
$(this).hide();
$(".tbl_comments").show();
//$("#loading").hide();
$("#comment").val("");
})
;
});
function validate(){
var comment = $('textarea[name=comment]').fieldValue();
if(!comment[0]){
$("#ptxt_green").fadeIn();
$("#ptxt_green").fadeOut(3000);
return false;
}
}
function goDelete(id){
if(xconfirm()){
//$('#comment'+id).fadeOut('slow');
$("#loading").show();
$.post('<?php echo url_for('seminar/delete'); ?>',{id:id},function(){
$("#loading").hide();
});
}
}
</script>
<?php $sf_response->setTitle(myTitleFactory::getPageTitle('seminar_detail', 'frontend',array('%seminar_title%'=>$seminar->getTitle())));?>
<?php myTools::loadBreadSlot(array(
myBreadcrumbFactory::get('seminar-list', 'frontend'),
myBreadcrumbFactory::get('seminar', 'frontend', array('slug' => $seminar->getSlug()), $seminar->getTitle())))
?>
<h1><?php echo $seminar->getTitle(); ?></h1>
<div class="table_seminar_wrap">
<table class="table_seminar" cellspacing="0" cellpadding="0" border="0" summary="info table">
<tr>
<th>Employee Id</th>
<td><?php echo $seminar->getId(); ?></td>
</tr>
<tr>
<th valign="top">情報公開日</th>
<td><?php echo $seminar->getPublishDate() .' '.$seminar->getPublishHour(); ?>時</td>
</tr>
<tr>
<th valign="top">セミナースキーム</th>
<td><?php echo $seminar->getStyle(); ?></td>
</tr>
<tr>
<th valign="top">日程</th>
<td><?php echo $seminar->getSeminarDate() .' '.$seminar->getStartTime() .' ~'.$seminar->getEndTime(); ?></td>
</tr>
<tr>
<th valign="top">前振りの文章</th>
<td><?php echo $seminar->getRawValue()->getSummary(); ?></td>
</tr>
<tr>
<th valign="top">タイトル</th>
<td><?php echo $seminar->getTitle(); ?></td>
</tr>
<tr>
<th valign="top">サブタイトル</th>
<td><?php echo $seminar->getSubTitle(); ?></td>
</tr>
<tr>
<th valign="top">開催地</th>
<td><?php echo $seminar->_getAddress(ESC_RAW); ?></td>
</tr>
<tr>
<th valign="top">会場</th>
<td>
<?php if($seminar->getLocationName()) : ?>
<?php echo $seminar->getLocationName(); ?><br>
<?php endif; ?>
<?php if($seminar->getRoomName()) : ?>
<?php echo $seminar->getRoomName(); ?>
<?php endif; ?>
</td>
</tr>
<?php if($seminar->getLocationName()) : ?>
<tr>
<th valign="top">会場URL</th>
<td><a href="<?php echo $seminar->getLocationUrl(); ?>" target="_blank" rel="nofollow"><?php echo $seminar->getLocationUrl(); ?></a></td>
</tr>
<?php endif; ?>
<tr>
<th valign="top">内容</th>
<td><?php echo $seminar->getRawValue()->getDetail(); ?></td>
</tr>
<tr>
<th valign="top">キーチャート</th>
<td>
<?php if($seminar->getImagePath()): ?>
<a href="<?php echo $seminar->getImagePath(); ?>" target="_blank">
<img style="width:300px;" src="<?php echo $seminar->getImagePath(); ?>"/></a>
<?php endif; ?>
</td>
</tr>
<tr>
<th valign="top">対象</th>
<td>
<?php foreach($seminar->getTarget() as $target): ?>
<?php echo $target; ?>
<?php endforeach;?>
</td>
</tr>
<tr>
<th valign="top">定員・残席状況</th>
<td><?php echo $seminar->getCapacity(); ?>人</td>
</tr>
<tr>
<th valign="top">参加料</th>
<td><?php echo $seminar->getPrice(); ?></td>
</tr>
<tr>
<th valign="top">担当者</th>
<td><?php echo $seminar->getEmployee()->getName(); ?></td>
</tr>
<tr>
<th valign="top">講師</th>
<td>
<img class="instructorImage" alt="Instructor Image" src="<?php echo $seminar->getInstructor()->_getImagePath(); ?>" /><br>
<span><?php echo $seminar->getInstructor()->getName(); ?><span>
</td>
</tr>
<tr>
<th valign="top" style="width:170px">ご参加の皆様へのメッセージ</th>
<td><?php echo $seminar->getRawValue()->getMessage(); ?></td>
</tr>
<?php if($sf_user->isAuthenticated() && !$seminarXPerson): ?>
<tr>
<td style="text-align:center;" colspan="2">
<div class="blueBtnLink">
<a href="<?php echo url_for('seminar/apply?id='.$seminar->getId()); ?>" title="応募する"><span>応募する</span></a>
</div>
</td>
</tr>
<?php elseif(!$sf_user->isAuthenticated()): ?>
<tr>
<td style="text-align:center;" colspan="2">
<div class="blueBtnLink">
<a href="<?php echo url_for('seminar/apply?id='.$seminar->getId()); ?>" title="応募する"><span>応募する</span></a>
</div>
</td>
</tr>
<?php endif; ?>
</table>
<div id="ptxt_green">
<p>Please Write A Comments. . .</p>
</div>
<br />
<?php if($sf_user->isAuthenticated()): ?>
<form id="comment_form" action="<?php echo url_for('seminar/comment'); ?>" method="post">
<textarea id="comment" name="comment"></textarea>
<input type="submit" value="Write Comments" />
<br />
<br />
<div id="loading" style="text-align:center;">
<img alt="" src="/images/loading.gif" />
</div>
<div class="result">
<table class="tbl_comments">
<tbody>
<?php foreach($comments as $x => $comment): ?>
<tr id="comment<?php echo $comment->getId(); ?>">
<td width="10%">Comments:</td>
<td>
<?php echo $comment->getComments(); ?><br />
<a href="javascript:;" title="delete" onclick="return goDelete(<?php echo $comment->getId(); ?>) " >Delete</a>
<a href="">Reply</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</form>
<?php endif; ?>
</div>
和我的控制器
<?php
/**
* seminar actions.
*/
class seminarActions extends sfActions{
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
/* public function preExecute(){
}*/
public function executeDelete(sfWebRequest $request){
echo "test"; exit();
$id = $request->getParameter('id');
if($id){
$comments = Doctrine_Core::getTable('SeminarsComment')->find($id);
$comments->delete();
}
return $this->renderText($id);
/*$this->id = $request->getParameter('id');
if(!$this->id){
$this->forward404();
}
$comment = SeminarsCommentTable::getInstance()->find($this->id);
$comment->delete();
*/
}
}
和我的routing.yml
seminar_delete:
url: /seminar/delete
param: { module: seminar, action: index }
答案 0 :(得分:0)
你得到什么错误?你在回答中看到“测试”吗?
首先,您的路由应该是
seminar_delete:
url: /seminar/delete
param: { module: seminar, action: delete }
行动:delete
,而非index