In Javascript you can send via post, with the jquery post method:
<script src="//code.jquery.com/jquery-latest.js" type="text/javascript"></script>
Putting 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);
}
});
});
});
On 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'));
}
um... $.ajax() ?
– SneepS NinjA
I get it, @Sneepsninja. He wants to do an ajax, but he doesn’t know it calls ajax :)
– Wallace Maxters