I’m trying to send over the data from my textarea using an ajax call to my PHP file, but we aren’t getting any response back from the PHP file.
<textarea id="area" cols="70" rows="30"></textarea> <button id="submit">Submit</button> <script> $('#submit').click(function (e) { e.preventDefault(); var info = $('#area').val(); $.ajax({ type: "POST", url: 'pages/assignments/response.php', data: {area: info} }); }); </script>
<?php if (!empty($_POST['area'])) { $success = json_encode('succes'); return $succes; }; ?>
— # Answer # —
I thought I had already tried an echo in this piece of code, but I think I just missed the output on the webpage and thought it wasn’t working.
<?php if (!empty($_POST['area'])) { echo "success"; }; ?>
Advertisement
Answer
Thanks Mickael for the answer!
I completely forgot to add an echo to my code.
<?php if (!empty($_POST['area'])) { $succes = json_encode('succes'); echo $succes(); }; ?>