Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to emulate XMLHttpRequest client using PHP?

I'm looking for an example how to emulate XMLHttpRequest client using PHP.

In other words, send the request over HTTP POST message, and receive and process the callback message.

like image 673
tputkonen Avatar asked Apr 27 '26 10:04

tputkonen


1 Answers

If you want to 'really' simulate an AJAX request, you should, together with all of the above solutions, consider sending this header with your request:

X-Requested-With: XMLHttpRequest

(check the manuals to the solutions how to set custom headers). Prototype, jQuery, mootools and the such all send this header when they request data via AJAX.

like image 69
Boldewyn Avatar answered Apr 29 '26 02:04

Boldewyn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!