In JavaScript you can send via post, with the jquery post method:
<script src="//code.jquery.com/jquery-latest.js" type="text/javascript"></script>
Placing the following script:
$(function() {
$('#sub').on('click',function() {
var data = {pagando: '<?php echo "xxxxx"; ?>'};
$.post('sua_pagina.php', data, function(rtn) {
var e = jQuery.parseJSON(rtn);
/* --- se prefirir, tem mais duas formas de fazer parse
var e = eval('('+rtn+')');
--- ou
var e = JSON.parse(rtn); */
if (e.success) {
alert(e.message);
}
});
});
});
In the body, put the button:
<input type="button" id="sub" value="PAGAR">
And in PHP, you do what you need and then return if you have a valid condition:
if (isset($_POST['pagando'])) {
//faz o que você quer aqui dentro
echo json_encode(array('message'=>'sucesso!', 'success'=>'1'));
}