私のajaxリクエストに関する問題が残っています。 目的は、データベースを更新するために値を送信するためにクリックすることができるボタンまたはリンクを含む複数の行を含むテーブルを持つことです。これが行われた後、ボタンまたはリンクはもうクリック可能ではなく、特定の行の純粋なテキストに置き換えます。特定の行のテーブルでajax経由で変数値を送信する
編集:@Sagar Aroraのおかげで、特定の行の特定の変数値を送信する作業コードが用意されていますが、そのボタンをクリックしたことがわかるようにボタンを純粋なテキストに置き換える必要があります。私はすべてのために感謝しています
// the update database query and execution (is already doing fine)
$request_id = $_POST['request_id'];
echo "test $request_id test";
:私のglobal.jsで
// Several table-rows before and after
// Problem is, the class "paid_button" also belongs to the other buttons in every other
// table row, but I want to adress them specifically to get the id of that row for the ajax
<td><button name="paid" value="<?php echo $id; ?>" class="paid_button">Bezahlt</button></td>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="../js/global.js"></script>
$(document).on("click",".paid_button",function(){
var current_element = $(this);
$.ajax({
type: "POST",
url: "https://www.xxx",
data: { 'paid': current_element.attr("value")},
success: function(data){
alert("ok");
this.attr("disabled","disabled");//this will disable the clicked button
}
});
});
updatePotatoe.php:
テストのために、私は次のようpotatoe.phpを持っていますヘルプとヒント!
が私の答え.Thisはあなたの問題を解決しますを確認してください。 –