Jump to content

Ajax Error


Frederick

Recommended Posts

I have two gateways that calls my app for callback reasons. One of them expects a "200" response and the other needs the "OK" response. In UniServerModule's OnHttpCommand event, I added the following code:-

    AResponseInfo.ContentText:='OK';
    AResponseInfo.ContentType := 'text/plain';
    AResponseInfo.ResponseNo:=200;

When I run the application, I get an "Ajax Error: OK is not defined" all the time.

What am I missing here and is my above code correct in returning the responses to the gateways?

--
Frederick
(UniGUI Complete - Professional Edition 1.90.0.1562)
 

Link to comment
Share on other sites

My app has one login form. Normally, when I call the app from the browser, the login form appears.

If I put the following code in UniServerModule's OnHttpCommand event, the browser displays an "OK" and then stops. The login form does not show.

    AResponseInfo.ContentText:='OK';
    AResponseInfo.ContentType := 'text/plain';
    AResponseInfo.ResponseNo:=200;
    Handled:=True;

How do get my app to return the response code of "OK" to my browser AND show the login form?

Link to comment
Share on other sites

1 hour ago, Frederick said:

My app has one login form. Normally, when I call the app from the browser, the login form appears.

If I put the following code in UniServerModule's OnHttpCommand event, the browser displays an "OK" and then stops. The login form does not show.

    AResponseInfo.ContentText:='OK';
    AResponseInfo.ContentType := 'text/plain';
    AResponseInfo.ResponseNo:=200;
    Handled:=True;

How do get my app to return the response code of "OK" to my browser AND show the login form?

@Frederickhello, try this:

UniServerModule's OnHttpCommand

var
oldContent : String;
begin
inherited;
    oldContent := AResponseInfo.ContentText;
    AResponseInfo.ContentText := 'OK';
    AResponseInfo.ContentType := 'text/plain';
    AResponseInfo.ResponseNo := 200;
    Handled := True;

    sleep (2000);//add a 2 second delay to get the first response (but may not be necessary)

    AResponseInfo.ContentText := oldContent;
    Handled := False;

end;

 

you can try this in UniGUIServerModuleHTTPDocument too.

 

Link to comment
Share on other sites

20 minutes ago, Frederick said:

Thanks for the code. This seems to work.

What advantage is there in using this code in UniGUIServerModuleHTTPDocument compared with in UniGUIServerModuleHTTPCommand?

nothing important, you can just try to return OK (200) when the document is filled not on every request.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...