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();
}