Answer the question
In order to leave comments, you need to log in
Is it possible to receive a request from a JS script?
I have a page bum.html
where there are only tags script
, and inside the JS script itself.
So, when I request this page, I send another request with AJAX.
For example, there is a page zapros.php
There I send a request like this: file_get_contents('https://site.com/bum.html');
The page bum.html
contains an ajax request to a site.
But nothing happens when file_get_contents()
you just go to the page - it works.
What could be the problem?
Answer the question
In order to leave comments, you need to log in
The problem is understanding where what is being executed.
PHP is executed on the server.
HTML is processed in the browser and JavaScript is executed in it (in the browser).
file_get_contents()
gets just a line of text. In order for the JavaScript contained in it to be executed, a browser or something that imitates it is needed.
To execute JavaScript on the server, use NodeJS.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question