提交表单而不刷新Jquery问题

时间:2013-10-01 08:46:42

标签: php html jquery

我有一个表单,在提交时它不会刷新。正如我看到其部分工作,但帖子数据似乎不起作用的部分。任何人都可以帮我修复此表单以发布数据应该

代码:

<script>
$(function(){
$("#submit_status").click(function(){
var status=$("#Status").val();
//
$.post("edit_status.php",{"Status":status,"client_id":<? echo $client_id ?>},function(){

});
});
})
</script>
<form name="statusF" id="statusF" method="post" action="edit_status.php" enctype="multipart/form-data">
<input type="text" id="client_id" name="client_id" style="display: none;" value="<? echo $client_id ?>" /> 
<table width="100%" border="0">
  <tr>
  <td>Status</td>
    <td>

    <?
    if ($status == "ACTIVE") {
$status_selectionA = "selected";
$status_selectionN = "";    
}
else{
    $status_selectionA = "";
$status_selectionN = "selected";
}
?>
    <select name="Status" id="Status" style="background-color: rgba(110, 225, 253, 0.62);border: none;height: 50px;font-style: italic;width: 290px;padding: 10px;margin: 5px;color: #358fa7;font-size: 14pt;font-family: Neo Sans Light, Verdana, Tahoma;border: none;float: left;" class="required">

<option value="YES" title="YES" <? echo $status_selectionA; ?>>Active</option>
    <option value="NO" title="NO" <? echo $status_selectionN; ?>>Not active</option>

</select>

    </td>
    <td><input type="submit" onclick="return false;" name="submit" style="display: none;" id="submit">
<label for="submit" class="add-client-button" style="margin:0;float: right;" id="submit_status">SAVE</label>

</td>
  </tr>
</table>
</form> 

1 个答案:

答案 0 :(得分:0)

使用以下代码..正常工作......

<?php $client_id= 0; ?>
<form name="statusF" id="statusF" method="post" action="edit_status.php" enctype="multipart/form-data">
 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(function(){
$("#submit_status").click(function(){
var status=$("#Status").val();

    $.post("edit_status.php",{"Status":status,"client_id":<? echo $client_id ?>},function(){
    });
});
});
</script>


<input type="text" id="client_id" name="client_id" style="display: none;" value="<? echo $client_id ?>" /> 
<table width="100%" border="0">
  <tr>
  <td>Status</td>
    <td>

    <?
    if ($status == "ACTIVE") {
$status_selectionA = "selected";
$status_selectionN = "";    
}
else{
    $status_selectionA = "";
$status_selectionN = "selected";
}
?>
    <select name="Status" id="Status" style="background-color: rgba(110, 225, 253, 0.62);border: none;height: 50px;font-style: italic;width: 290px;padding: 10px;margin: 5px;color: #358fa7;font-size: 14pt;font-family: Neo Sans Light, Verdana, Tahoma;border: none;float: left;" class="required">

<option value="YES" title="YES" <? echo $status_selectionA; ?>>Active</option>
    <option value="NO" title="NO" <? echo $status_selectionN; ?>>Not active</option>

</select>

    </td>
    <td><input type="submit" onclick="return false;" name="submit" style="display: none;" id="submit">
<label for="submit" class="add-client-button" style="margin:0;float: right;" id="submit_status">SAVE</label>

</td>
  </tr>
</table>
</form>