0

I am using the following to get js variables to a php file. The alert seems to be given the correct data.

   var str =  $("form").serialize();
        alert('test '+str);
        //console.log('test '+str);
        $.ajax({
            type:"POST",
            url: "saveData.php",
            data: str,

and i the php file i tried

echo 'Test name: '.$_REQUEST["name"];//only got the test name

also print_r($_REQUEST);

and even tried

$values = array();
parse_str($_REQUEST['str'], $values);
print_r($values);

But without succes, any tips or info?

1
  • What is the value of str? Commented Feb 13, 2013 at 15:12

1 Answer 1

2

data should be done as follows:

   var str =  $("form").serialize();
        $.ajax({
            type:"POST",
            url: "saveData.php",
            data: {name: str},

This way you should be able to obtain the value in PHP via $_REQUEST["name"]

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.