I am trying to use AJAX to pass a JavaScript array to a PHP array but the problem with me that I got no response in my PHP side. I make the request in the same page not to another page. The problem is that I got no response from the PHP side although I got alert "Success" from the AJAX side error in console: https://drive.google.com/file/d/10KgUcy4WIHTbKbWY6QJvyJi6c_26Qxz8/view?usp=sharing here is my PHP side which I suppose to get my requested data.
<?php
if( isset($_POST['myData']) )
{
console.log("i am here");}
?>
and here my script and AJAX request
<script type="text/javascript">
let arr = [1,2,3];
var str_array = arr;
var request = $.ajax({
method: "POST",
data: { myData : JSON.stringify(str_array) },
dataType: "html"
});
request.done(function( msg ) {
// ajax response
alert("Success!!");
});
request.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
</script>