Reputation: 9
Hi im making an ajaxForm using comments.My problem is why the error is 500 Internal Server Error???, Well my codes and js library are in there, i dont quite understand why 500 internal server error.. Here's my code below.
<script>
$(document).ready(function(){
$("#tbl_comments").hide();
//$("#loading").hide();
$("#ptxt_green").hide();
$('#comment_form').ajaxForm({
target: '.result',
beforeSubmit: validate,
success: function(data) {
alert(data);
}
});
$("#loading")
.hide()
$(".result").show()
.ajaxStart(function(){
$(this).show();
$(".result").hide();
$("#loading").show();
})
.ajaxStop(function(){
$(this).hide();
$(".result").show();
})
;
});
function validate(){
var comment = $('textarea[name=txt_comment]').fieldValue();
if(!comment[0]){
$("#ptxt_green").fadeIn();
$("#ptxt_green").fadeOut(3000);
return false;
}
}
</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="txt_comment" name="txt_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 id="tbl_comments">
<tr>
<td width="10%">Comments:</td>
<td>asasa</td>
</tr>
</table>
</div>
</form>
<?php endif; ?>
</div>
and my php file is this one
<?php
class commentAction extends sfAction{
public function execute($request){
echo "test"; exit();
//echo "qwqqwqqw"; exit();
//$post = $request->getParameter('seminar');
////print_r($post);exit();
//$comment = new SeminarComments();
//$comment->setComments($post['txt_comment']);
//$comment->save();
//$this->redirect('seminar');
}
}
?>
there.Why 500 internal server error? is this from the js? error? neeeeeeeeeeed badly help
Upvotes: 0
Views: 1140
Reputation: 10890
Try to call dev controller from your ajaxCall.
Normally you call index.php
which is production controller and it doesn't provide any useful information about the error. Try to call front_dev.php
instead which will return additional information about an error.
(the name of your dev controller is usually your app name suffixed with _dev.php
so front_dev.php
assumes your app name is front, which is default btw)
Upvotes: 0
Reputation: 10585
You have not provided enough info for anyone to give you a definitive answer, but here are some troubleshooting tips:
Check your server logs. To find where they are, see https://serverfault.com/questions/287079/cant-find-apache-error-logs and try to grep
it out, here are a few to try (stolen directly from referenced ServerFault question)
grep ErrorLog /usr/local/etc/apache22/httpd.conf
grep ErrorLog /etc/apache2/apache2.conf
grep ErrorLog /etc/httpd/conf/httpd.conf
Once you find your server logs, find the log entry that corresponds to your 500 error. If you are having a hard time finding it, make another request with your client and then try to find the latest log entries.
Possible sources of error in your JavaScript include:
By the way the server-side code you have posted does not tell the whole story. It is a simple class but rests on top of a complex framework, and you need to check the framework configuration to see if all is well. In particular, try calling the action directly (ie in your web browser, NOT through jQuery/JS). If it doesn't work, try calling a different action and see if it works. If you cannot get any action to work, it might be a framework config issue. I'm not familiar with symfony but if I were forced to become so I would start there.
If you can provide us the error log it would help greatly.
Upvotes: 1