0

This question may be very stupid, but i'm a beginner in web development and I would like to know if there is a way to send JSON string to a php file without using AJAX?

I had a Exam question like this : "Submit the JSON object to the PHP file. In the PHP file you must convert the JSON string into a PHP object."

How this would be possible without AJAX?

Thank you

19
  • json($data); $data containing serialized objects for instance :) Commented Nov 20, 2013 at 21:23
  • Every method that allows you to send data, e.g. curl Commented Nov 20, 2013 at 21:25
  • 2
    You can put the JSON string in a hidden form input, and then submit the form normally instead of using AJAX. Commented Nov 20, 2013 at 21:25
  • Can you help me with some topic to search on google to understand better what you have just said? @KA_lin Commented Nov 20, 2013 at 21:26
  • 1
    @Barmar...you are right, i didn't read the JS part of the question....oooh wait, that part doesn't exist!!! Commented Nov 20, 2013 at 21:33

1 Answer 1

2

in html page:

<a href="http://phpfile.php?jsonstring=%7B%22a%22%3A1%7D">send, receive and convert</a>

in phpfile.php:

$json = json_decode($_REQUEST['jsonstring']);
var_dump($json);

result is:

$json = ["a" => 1]
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.