How to pass variable in javascript for query in php using ajax -
i want use value input file hidden when doing click on href.
<a href="#" onclick="invoice_open(<?php echo $counter?>);">confirm</a> function invoice_open(i){ var x = document.getelementbyid("inv"+i).value; alert(x); window.scrollto(0,0); document.getelementbyid('light').style.display='block'; document.getelementbyid('fade').style.display='block'; }
i success value input type hidden (var x), don't know how pass x value php ex. $result = x.
i want use $result display data database. please help. thank you
since values using <?php echo $counter?>
can
var counter = '<?php echo $counter?>'
in javascript. , typical ajax approach following..
$.ajax({ url: 'index.php&counter=' + counter, datatype: 'json', beforesend: function() { }, complete: function() { }, success: function(json) { // dom, redirect ... etc }, error: function(xhr, ajaxoptions, thrownerror) { // handles exception } });
Comments
Post a Comment