I have this code where I need to pass the value of the "totalcompra" id to another page. page1.html
<div id="total">
<div class="container-total">
<div class="text-total">
<p>Total:$</p><p id="totalcompra" name="totalcompra"></p>
</div>
<div class="ahr">
<input type="submit" id="compra_segura" class="submit btn btn-success action-button" value="Compra Segura"/>
</div>
</div>
</div>
And I want to put the value here.
page2.html
<aside>
<div id="side-container">
<h2 class="quoter-text">Resumen de compra</h2>
<div class="rsm"></div>
<div class="pymt-total"><p class="total-pym">Total:</p></div>
</div>
</aside>
ajax
$('#compra_segura').click(function() {
$.ajax({
type: 'POST',
url: '/payment/',
data: { total : $('#totalcompra').text() },
success: function(data)
{
$('.total-pym').html(data);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
I've tried doing it with ajax and jquery but I have not been successful. How can I do it? Thank you.