1
To working on a plane table, which has a script with multiple objects, thus:
var plano_basicoUS = {
1: null, // mensal
2: null, // trimestral
3: null, // semestral
4: null, // anual
};
var plano_economicoUS = {
1: null, // mensal
2: null, // trimestral
3: null, // semestral
4: null, // anual
};
I update the values of each one via $.get
, thus:
$.get("buscar_valor.php?id=3&periodicidade=monthly", function(resultado){
plano_basicoUS[1] = parseFloat(resultado);
});
$.get("buscar_valor.php?id=3&periodicidade=quarterly", function(resultado){
plano_basicoUS[2] = parseFloat(resultado);
});
$.get("buscar_valor.php?id=3&periodicidade=semiannually", function(resultado){
plano_basicoUS[3] = parseFloat(resultado);
});
$.get("buscar_valor.php?id=3&periodicidade=annually", function(resultado){
plano_basicoUS[4] = parseFloat(resultado);
});
$.get("buscar_valor.php?id=4&periodicidade=monthly", function(resultado){
plano_economicoUS[1] = parseFloat(resultado);
});
$.get("buscar_valor.php?id=4&periodicidade=quarterly", function(resultado){
plano_economicoUS[2] = parseFloat(resultado);
});
$.get("buscar_valor.php?id=4&periodicidade=semiannually", function(resultado){
plano_economicoUS[3] = parseFloat(resultado);
});
$.get("buscar_valor.php?id=4&periodicidade=annually", function(resultado){
plano_economicoUS[4] = parseFloat(resultado);
});
Each query of $.get
returns a value like: 10.00, through the PHP file.
As there are several objects, I would not have to repeat the gets for each one.
How can I do this dynamically, noting that each $.get
has a different URL? Or sequentially, if applicable.
All right, I just couldn’t get them to charge, just like that flame() function you had me on.
– Wendler
I made a change that creates the objects automatically.
– Sam
On the question of function
chama
, you don’t even need to put a value, already automatic grip:function chama(){
 if(contagets == valores.length-1){
 $("select.periodicidades").trigger('change');
 }
}
– Sam
And you call the function
chama();
within $.get before that if:if(contavalores == 4){
.– Sam
It worked, but only loaded the foreground values.
– Wendler
Have a look at the source code: http://dvdteste.hostgemdesites.ws/teste.php
– Sam
Oh yes, I had put in the wrong place the
chama();
. How would it be for him to load the values together with the page loading?– Wendler
The answer has. Just call the function
carregaObjs();
– Sam
Something like that?
$(document).ready(function () {
 carregaObjs();
});
– Wendler
In this case it would not be necessary to call() the function right? because it will load the whole function.
– Wendler
When adding more items need to update some value? Because I put 5 select, and it didn’t work. I updated tbm values in:
var valores
and of the initial objects.– Wendler
No, it’s all automatic. You just need to add in the array
valores
.– Sam
Let’s go continue this discussion in chat.
– Sam
Take away one more doubt?
– Wendler
can help me update the script to display the coin value with mile score?
– Wendler