Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

321
Visualizações
AJAX: Can I POST an array/data from my GET request? (Flask)

question similar to AJAX/FLASK/JS: How to POST existing array into endpoint?, a new question I've posted but this doesn't specifically help with the new issue, sorry about that.

I am tying to POST an array, specifically the songFiles array, I have pushed with data from my AJAX GET request. Is there any way I can do this in the same call or any solution at all? Been trying to rack my brain, any help is welcomed, thanks :).

[My first question here, so I might be missing something]

    function getTableData(callback) {
    $.ajax({
        method: 'GET',
        url: '/api/getSong',
        dataType: 'json',
        success: function(data) {
            createMusicTable();
            
            let indexObj = Object.keys(data.song).length;
            
            for (var i = 0; i < indexObj; i++) {
                var song = data.song[i]
                var id = data.song[i].song_id;
                var fileName = data.song[i].song_file + '.mp3';
                
                songFiles.push(fileName);
                appendMusic(song, id);
                
                songTitle.id = "s" + i;
                console.log("td-ok");
                callback(songFiles);
            }
        }
    });
}

function callback(result){
    return fileNames 
}

EDIT FOR COMMENT:

success: function(data) {
           // CODE HERE BLAH BLAH 
                $.ajax({
                    method: 'POST',
                    url: '/someURL',
                    dataType: 'json',
                    success: function(data) {
                       
                    }
                });
            }
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Your question technically asks whether one can send a POST request from a GET request. Another possibility is that you want to send a POST request from the client-side once the GET request completed.

If you want to send it from your GET request, then you will need to modify the /api/getSong endpoint so that it will trigger a POST request from your server. If you do not want to wait for it, you can do it asynchronously. If you intend to wait for it, then you need to do it synchronously. You can build up your response as you like.

If you want to send the POST request from the client-side, then you will need to send it from the success callback.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda