[fpc-pascal] fpweb and reading the contents of a request

Michael Van Canneyt michael at freepascal.org
Mon Oct 17 15:55:48 CEST 2011



On Mon, 17 Oct 2011, Felipe Monteiro de Carvalho wrote:

> Hello,
>
> I am trying to send data from javascript and read data back from my
> cgi module with this:
>
>  SendSyncRequest = function(RequestURL, RequestContent)
>  {
>    var request = new XMLHttpRequest();
>    request.open('GET', RequestURL, false);
>    request.setRequestHeader('Content-Type', 'text/html');
>    request.send(RequestContent);
>    //debugDiv.innerHTML = debugDiv.innerHTML + "after send<br>";
>    return request.responseText;

As far as I know, this will always be empty, 
for the simple reason that the request is executed asynchronously. 
You must attach a callback which is executed once the request is 
ready, and read ResponseText after that.

Michael.



More information about the fpc-pascal mailing list