Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

100
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!