0

I have a PHP page with $_POST and $_FILES data filled in. The POST data was obtained not from a traditional HTML form, but between multiple pages.

For example, the POST data is a number of things:

$_POST["username"]
$_POST["password"]
$_FILES
etc.

The question is, how do I send this POST data off to an AJAX call within the page?

I know with a form it's something like this:

$.ajax({
   type: 'post',
   url: 'post.php',
   data: $('form').serialize(),
   success: function () {
     alert('form was submitted');
   }
 });

But what about directly from PHP's POST data?

Ethan Allen
  • 14,425
  • 24
  • 101
  • 194

1 Answers1

0

The question is, how do I send this POST data off to an AJAX call within the page?

You can use WebSocket or EventSource and possibly ServiceWorker to stream data from server to client. For example, see How to read and echo file size of uploaded file being written at server in real time without blocking at both server and client? where the requirement is to stream the progress of bytes of uploaded file being written to file at server by php in real time without blocking.

guest271314
  • 1
  • 15
  • 104
  • 177