I would like to have the following:
The user submits the form with a click ( index.php ), the input of the form is processed by an external PHP file ( search.php ), and the results are published on the original page ( index.php ) in a div.
I have already compiled most of the code. It submits the form on click and submits it to a PHP script.
Now I need the result of the PHP script to return to the original page ( index.php ).
Here is my code:
function submit() { $(function() { var id = "id"; var dataString = 'id=' + id; $.ajax({ type: "POST", url: "inc/search.php", data: dataString, success: function() { goToByScroll("result"); $('#result').html("<br><br><br><br><br><br><br><br><br><br>< div class='center'><img src='img/loader.gif' /></div>").hide().fadeIn(2500, function() { $('#result').html("Finished"); }); } }); return false; }); }
My PHP file (for testing):
<?php function safe($value) { htmlentities($value, ENT_QUOTES, 'utf-8'); return $value; } if (isset($_POST['id'])) { $id = safe($_POST['id']); echo ($id); } elseif (!isset($_POST['id'])) { header('Location: error?id=notfound'); } ?>
I would like to get results from search.php (in this case "id") sent to #result, but I canβt understand how: S
source share