0

I am having the below ajax call to php which is not working.

  var data = ['test1','test2'];
  $(document).ready(function(){
    $(".button").click(function() {        

        $.ajax({        
            type: "POST",
            url: "getResult.php",
            data: {testData : data },
            success: function(data) { 
                alert("Data: " + data);
            } 
        });      
    return false; 
    });  
  });

PHP side -

$myArray = $_REQUEST['testData'];
echo $myArray;

Requesting expects to help me.

1 Answer 1

1

This should do the trick:

    $myArray = $_POST['testData']; 
Sign up to request clarification or add additional context in comments.

6 Comments

I tried $myArray = $_POST['testData']; and still not working. I guess the request is not being received or rather not sent!
Is the alert being triggered at all?
No, the alert is not being triggered at all.
trying changing data to "data: { testData : 'StringTest' },". See if it fires back the alert.
changed data to "data: { testData : 'StringTest' },". Still alert is not triggered. Is there any way to check server error here?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.