How do I call a php on a server?

I need to call a php script on my server, which will return some database value.
How do i call the php?
TWebHTTPRequest seems not to work and return always an error, for example, when I call:

WebHttpRequest1.URL:='https://www.google.com';
WebHttpRequest1.Execute;

I get always an error in the console:

ERROR
HTTP request error @https://www.google.com | fMessage::HTTP request error @https://www.google.com fHelpContext::0 FJSError::Error: HTTP request error @https://www.google.com
at http://localhost:8000/Project2/Project2.js [54024:21]

So how do I call a php script, or read the content of a html page from a server like I can do with indy?

I cannot speak for your PHP server but Google has CORS disabled.

See:



So there is no HTTP library to do a simple GET to an URL, just like I can do in Delphi with Indy or other?
ANY address I use with webhttprequest will fail for me.

To make it more clear:
I have a text file "test.txt" on my server. How can I read it with web core?

I have given 3 links that explain the phenomenon you see.
TWebHttpRequest is the component with which to do HTTP requests.
Web applications run in a web browser and a web browser is a secure sandbox environment that implements its own security techniques and part of that is CORS. So, if you want to use a HTTP GET request to get a TXT file, you either need to do this from the domain where your web application is running from or enable CORS on the server on another domain where the TXT file is hosted.
Please read the information in the 3 links I sent in the previous reply.

Ok, I found a Chrome extension toggle cors in Chrome, without modifying the server, that works now., Thanks.

That is fine for me but it is not a proper or correct solution.
It implicates that any user of this web application would need to install this extension.
The one and only correct solution is to enable CORS or on the server or to host the web client application on the same domain as the REST server.

No, thats only when I run it local during development and it access a php on my server. Once its on the server, it will work fine.