2
I have this sum1 variable in javascript and would like to send it to php how can I do this ?
JS
var sum1 = 0.0;
$('.class_nao_pago').each(function()
{
sum1 += parseFloat($(this).text());
PHP
echo $sum1
2
I have this sum1 variable in javascript and would like to send it to php how can I do this ?
JS
var sum1 = 0.0;
$('.class_nao_pago').each(function()
{
sum1 += parseFloat($(this).text());
PHP
echo $sum1
1
You can only do this if you call a page via AJAX (by post or get) or create a form in your main html that sends this variable to a PHP page.
This integration you’re trying to accomplish has no way of happening.
Take this example:
var sum1 = 0.0
$('.class_nao_pago').each(function()
{
sum1 += parseFloat($(this).text());
});
$.post('URL da página PHP', {'soma':sum1})
.done(function(data){
//callback
});
Or by GET
var sum1 = 0.0
$('.class_nao_pago').each(function()
{
sum1 += parseFloat($(this).text());
});
$.get('URL da página PHP', {'soma':sum1})
.done(function(data){
//callback
});
Browser other questions tagged php javascript
You are not signed in. Login or sign up in order to post.
Submit or ajax.
– rray