Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

99
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda