Eavis / web_app

0 stars 0 forks source link

php_json_python #32

Open Eavis opened 7 years ago

Eavis commented 7 years ago
json_for_send = JSON.stringify(json_join);
      $.ajax({
        type: 'POST',
        url: 'db/multiCoeff.php',
        // contentType: "application/json; charset=utf-8",
        // dataType:"text",
        // dataType: "json",
        data: {'categories': json_for_send},
        success: function(msg) {
          // var msg_rcv = JSON.parse(msg);
          // console.log(msg);
          alert(msg);
        }
      });
<?php
  if(isset($_POST['categories'])) {
    $json = $_POST['categories'];
    $results = json_decode($json);

?>
Eavis commented 7 years ago

before write file to local folder remember to chmod of the folder

if (file_put_contents("../python/data.json", $json))
        echo "JSON file created successfully...";
    else
        echo "Oops! Error creating json file...";