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

101
Visualizações
Passing Javascript Array to php function and call another php function using ajax

I have this button here to call Javascript function

<button class=" btn-primary border border-primary rounded p-2 ms-auto " id="proceed" onclick="proceed_tags()">Proceed </button>

The function is to pass selected_keywords_arr Array to controller/keywords_suggestion.php

function proceed_tags(){


        if (selected_keywords_arr === undefined || selected_keywords_arr.length == 0) {
            // array empty or does not exist
            alert("you have to select keywords first");
            return;
        }
        var Tags_Data = JSON.stringify(selected_keywords_arr);
        alert("button clicked");

          $.ajax({
           type: "POST",
           url: 'controller/keywords_suggestion.php',
           data:{action,Tags_Data },
           success:function(Success) {
             alert(Success);
           }

      });
       
    }

here in controller/keywords_suggestion.php I'm trying to capture the array and to check if the button clicked to execute another function but it prints this error [Wed Mar 16 18:16:59.919632 2022] [php:warn] [pid 7488:tid 1852] [client ::1:65035] PHP Warning: Undefined array key "action" in C:\\xampp\\htdocs\\seosystem\\controller\\keywords_suggestion.php on line 25

$keyword_tags_arr = json_decode($_POST['action'],true);

 
 
     if(isset($_POST["action"])){
    var_dump($keyword_tags_arr);
    echo "  <script type=\"text/javascript\"> alert(\"Helllllo\");  ";
    $Keywords_analysis_objj = new Keywords_analysis();
    $Keywords_analysis_objj->Keywords_title_desc();

}
about 4 years ago · Juan Pablo Isaza
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