2013-10-01 124 views
0

我有一個表單提交它不會刷新。正如我看到它的部分工作,但職位數據似乎不工作的部分。誰能幫我解決這個格式如發佈數據。應該無刷新提交表單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> 
+0

究竟是不是工作?你的控制檯是否有錯誤? –

+0

我認爲不,當我刷新頁面時,數據不會更新 –

+0

我希望我能幫忙,但我做了這個小提琴:http://jsfiddle.net/37sCF/ – pablofiumara

回答

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> 
+0

感謝Mandip對我也很有幫助。 – w3b

+1

歡迎@HarshVora .... :-) –