Get response from PHP file using AJAX -
so here's issue, using ajax (jquery) post form process.php
page needs echo out response such apple
or plum
. i'm not sure how take response process.php
, have stored variable...
here's code have far:
<script type="text/javascript"> function returnwasset(){ alert('return sent'); $.ajax({ type: "post", url: "process.php", data: somedata; success function(){ //echo server sent back... } }); } </script>
also need echo response in process.php
in json? or plain text fine?
sorry if sounds stupid question, first time doing such in ajax.
ps: how name post request in above code?
<?php echo 'apple'; ?>
pretty much literally need on server.
as js side, output of server-side script passed parameter success handler function, you'd have
success: function(data) { alert(data); // apple }
php ajax
No comments:
Post a Comment