How to make an ajax request for?

Asked

Viewed 65 times

2

Why doesn’t it work? I say it shows twice my Alert and then to, being that the value of aux_count is 17.

for(var i = aux_cont; i > 0; i++ ){
    var eval_data = eval(obj_grafico[aux_cont].series);

    alert(aux_cont);
    alert(i);

    $.ajax({
        type:"POST",
        url:"../../tmp/cria_json_pan_servidor.php",
        data:{
            montante_y:obj_grafico[i].montante_y,
            tickInterval_y:obj_grafico[i].tickInterval_y,
            min_y:obj_grafico[i].min_y,
            max_y:obj_grafico[i].max_y,
            min_x:obj_grafico[i].min_x,
            max_x:obj_grafico[i].max_x,
            tickInterval_x:obj_grafico[i].tickInterval_x,
            filename:obj_grafico[i].filename,
        },
        cache:false
    });
}

inserir a descrição da imagem aqui

below how I define the values of my object:

obj_grafico[aux_cont] = {

        montante_y: montante_y,
        tickInterval: intervalo_y,
        min_y: min_y,
        max_y: max_y,
        min_x: min_x,
        max_x: max_x,
        tickInterval: intervalo_x,
        tickAmount: montante_x,
        series: seriesOptions,
        filename: hostname

    }
  • You can change the image by the pf code?

  • @Lucascosta altered it

  • 1

    I think if you’re wrong, it wouldn’t be for(var i = 0; i < aux_cont; i++ ){? And check the console for any error messages..

1 answer

1


I think yours is wrong...
I believe that the value of aux_cont is already 17 before the is
Try it this way:

for(var i = 0; i < aux_cont; i++ ){
    var eval_data = eval(obj_grafico[i].series);

    alert(aux_cont);
    alert(i);

    $.ajax({
        type:"POST",
        url:"../../tmp/cria_json_pan_servidor.php",
        data:{
            montante_y:obj_grafico[i].montante_y,
            tickInterval_y:obj_grafico[i].tickInterval_y,
            min_y:obj_grafico[i].min_y,
            max_y:obj_grafico[i].max_y,
            min_x:obj_grafico[i].min_x,
            max_x:obj_grafico[i].max_x,
            tickInterval_x:obj_grafico[i].tickInterval_x,
            filename:obj_grafico[i].filename,
        },
        cache:false
    });
}
  • appears 17, 0 and then ends, but this error in the console I’ll fix and tell you

  • That code is weird... For example, what is the function of the eval_data variable, since you n use it down?(check if the browser console is not pointing out an error...) and tell me one thing just for me understand, the aux_count already comes with the value of 17 and is immutable, right?

  • Yes the Eval was an attempt to debug, the value of 17 is filled in according to a request made before, look at the mistake of that bizzaro (posted photo)

  • when I call obj_grafico[i]. filename in a function other than the one I’m setting my obj_chart variable it pops this error because this is occurring?

  • a look or a debug in the obj_graph array. The error says that the filename property is not there.. Maybe the array doesn’t have 17 positions either.... It would be a good thing if you put your entire code into a jsfiddle or even your msm question, so I can analyze the code better

  • I set as attribute the values of my object, see if it is coherent. Matheus my object variable is only showing if I put Alert inside the ajax request outside it from the error, which may be?

  • problem was no., it is possible to make several ajax requests

Show 2 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.