1

Gudday 伙计们,在使用 jquery 的方法远程加载表单后,我在将表单成功发布到数据库后遇到了一点挑战load(),它在 google chrome 中工作,但在使用 firefox 时不工作。感谢您的帮助。

PHP 代码。

<?php
        include 'login.php';
  if( isset($_POST['c_title']) && isset($_POST['c_code']) && isset($_POST['staff_id'])&& isset($_POST['staff_fulname'])
  && isset($_POST['c_desc'])&& isset($_POST['unit']) ){

      $c_title = sanitize_string($_POST['c_title']);
      $c_code = sanitize_string($_POST['c_code']); 
      $staff_id = sanitize_string($_POST['staff_id']);
      $staff_fulname= sanitize_string($_POST['staff_fulname']); 
      $c_desc = sanitize_string($_POST['c_desc']);
      $unit = sanitize_string($_POST['unit']); 



      $sql = " insert into course values('$c_title','$c_code','$staff_id','$staff_fulname','$c_desc','$unit') ";

      $result = mysql_query($sql);

      if($result){
        // echo '<br/> <div align="center"><small class="alert alert-success">&radic; Saved Successfully!</small></div>';
        echo '<script>alert("Saved Successfully!");</script>';
      }
      else{
          echo '<script>alert("Error Occured!");</script>';
      }



  }

   function sanitize_string($var){
    $var = mysql_real_escape_string($var);
    $var = htmlentities($var);
    $var = stripslashes($var);

    return $var;
   }
  ?>

<body>




<div class="container5">
<div align="center"><h3 class="btn-danger">Course Details</h3></div>
<div class="row">

<div class="span12">

<br/>
<div class="row">
<form id ="course_form" action="" method="post">
<div class="span6">
<div align="center">
Course Title:<input type="text" name="c_title" required/>
</div></div>

<div align="right">
<div class="span6">
Course Code:<input type="text" name="c_code" required/>
</select>
</div>
</div></div></div>
</div>

<div class="row">

<div class="span12">

<div class="row">


<div class="span6">
<div align="center">
Staff ID:<input type="text" name="staff_id" required/>
</div></div>
<div class="span6">
<div align="right">
Staff FullName:<input type="text" name="staff_fulname" required/>
</div></div>
<br/>
</div></div></div>

<div class="row">

<div class="span12">

<div class="row">


<div class="span6">
<div align="center">
Course Description:<textarea name ="c_desc" rows="3"></textarea>
</div></div>
<div class="span6">
<div align="right">
Unit Load:<select name="unit"> <option>1</option><option>2</option><option>3</option><option>4</option><option>6</option> </select></div>
</div>
<br/>
</div></div></div>

<div align="center"><button id="save2" class=" btn btn-danger">Save</button>
</form>

</div>
</body>

<script>
$(document).ready(function() {
$("#save2").click(function(){
            $.ajax({
            type: "POST",
        url: "course.php",
        data: $('#course_form').serialize(),
            success: function(msg){
                  alert("Saved Successfully");
                },
        error: function(){
            alert("Error has occurred");
            return
        }
            });
         })
});
         </script>
4

0 回答 0