-4

I have the following code :

$('#postTrx').click(function(){
    var hargaBrg = $("tbody").find("tr").eq(i).find("td").eq(3).text();
    var id = $("tbody").find("tr").eq(i).find("td").eq(0).text();
    var jumlah = $("tbody").find("tr").eq(i).find("td").eq(4).text();
    $.ajax({    
        type : "post",
        url : "input_pembelian.php",
        data: "{'idBeliBarang':" + id + ",'harga':'" + hargaBrg + "','jumlah':'" + jumlah + "}",                    
    }); 
});

How can I access a jQuery variable from AJAX?

Obsidian Age
  • 41,205
  • 10
  • 48
  • 71
Pri Yanto
  • 23
  • 1
  • 4

1 Answers1

0

i was try with following code, and response is complete, but no data insert into database, and i was check the query is right :

$('#postTrx').click(function(){
var hargaBrg = $("tbody").find("tr").eq(1).find("td").eq(1).text();
var id = $("tbody").find("tr").eq(1).find("td").eq(0).text();
var jumlah = $("tbody").find("tr").eq(1).find("td").eq(2).text();


$.ajax({    
    type : "post",
    url : "input_pembelian.php",
    data: "{'idBeliBarang':" + id + ",'harga':'" + hargaBrg + "','jumlah':'" + jumlah + "}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function () {
        alert("complete");
     },
    error: function (err) {
        alert(err);
    }   
}); 

});

Pri Yanto
  • 23
  • 1
  • 4