douque8855 2013-11-20 03:40
浏览 37

ajaxForm 500内部服务器错误

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

  • 写回答

2条回答 默认 最新

  • duanhan4763 2013-11-20 07:22
    关注

    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:

    • Calling the wrong URL
    • Calling the right URL but with the wrong parameters
    • Calling the right URL and parameters but with the wrong format (ie JSON vs XML)
    • Calling the right URL, parameters, and format but with wrong method (ie GET vs POST)
    • Calling the right URL/parameters/format/method but sending bogus data that the web server rejects (ie some servers are configured to automatically reject certain strings that look malicious)

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大