0

I have an AJAX function like below, which will send a Json data to PHP file, How can I get these data in PHP file ?

$.ajax({
    type: 'POST',
    url: 'data11.php',
    data: {
        json: ko.toJSON(viewModel)
    },
    success: function () {}
});

My Json data is something like below

{"participants":[{"NoPrticiField":1,"empname":"gfh","designation":"fh","email":"fgh"},{"NoPrticiField":2,"empname":"fgh","designation":"fgh","email":"fgh"}]}:
1
  • json_decode($_POST['json']); Commented Feb 27, 2014 at 7:11

1 Answer 1

1

Variables will be stored in either the $_POST or $_GET global variable.

You can retrieve it with the following:

$_POST['json'];

You can then also decode it with:

json_decode($_POST['json']);

Essentially PHP automatically stores all post and get variables into a sort of dictionary for you.

Take a look at:

https://www.php.net/manual/de/reserved.variables.post.php https://www.php.net/manual/de/reserved.variables.get.php

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.