Author Topic: Is it possible to update values on a Web Page without loading the entire page?  (Read 46114 times)

Offline hervé

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Hi Mark,

Thanks a lot, it's so simple when you explain.

When I try with the "normal code" I got an answer from the web server through the user files (ajax1)..
When I intercept inside fnDoWebPage() I got no answer
Is it enough to call fnSendTCP() with usLen set to the data length of ucTCP_Message ?

Thanks.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Hi Hervé

Calling fnSendTCP() will always send data if the socket is open. However when answering in this case the data should be inserted after an HTTP header which will be sent by the HTTP server. This means that it falls under "dynamic content generation". fnSendTCP() is use by the dynamic content generation code but together with other mechanisms.

If possible I would use the built-in mechanism. I am sure that it is not the only method but is is probably the simplest.

Regards

Mark

Offline hervé

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Hi Mark

I will manage with the built-in mechanism.

When I test the counter with http://192.168.167.205/XML?Dummy, it increases every two.
Then I put a breakpoint on
Code: [Select]
                     fnBufferDec(ucTestCounter++, 0, cValue);and it's called twice effectively.
Do you know why ?

Regards


Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Hi Hervé

Yes I know why this happens. It is because the dynamic insertion (can) call the function more than once as it is building TCP frames.
If I remember correctly it sometimes calls the code to generate the content and doesn't send it since the complete frame doesn't fit into the TCP frame. Then it has to call it again for the next frame.
The same happens when a TCP repetition is made and ff you have multiple sessions monitoring the variable it will also get incremented much faster since it will be incremented by each TCP connection...

Therefore the test case is in fact not a very representative test since it uses the content generation to increment the variable although the content generation will not necessarily take place just once.

The idea was to show a very simple case of variables being modified - in a real example the variable wouldn't (normally) not be changed due to the fact that the content was generated but due to other, unrelated factors (like seconds passing, inputs being detected, etc.). In fact it would be better to display the value of the system Tick for example:

In webInterface.c, fnInsertString():

            case '4':
                fnBufferDec(uTaskerSystemTick, 0, cValue);               // display the present TICK value
                cPtr = cValue;
                break;


Regards

Mark

Offline hervé

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Hi Mark,

I'm using <Dummy>£vX4</Dummy> now, thanks.

1/ Still have some question : cucXML_header never seems to be use, is it right?
2/ I'm trying to get the XML response on IE6, but in fact it works only when using responseText not responseXML : The format is not correct for IE, may be; do you note the same behaviour ? (I had no problem with FF...)

Thanks.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3243
    • View Profile
    • uTasker
Hi Hervé

1) I don't know where you have cucXML_header from. In which code is that?

2) I have to admit to not having used this technology much and so I don't have much experience with it and also don't know many details about it. When I try the http://192.168.0.3/XML?Dummy test there are however differences in behavior between firefox and IE8 (I don't know about IE6).
Firefox displays <Dummy>4232</Dummy> and IE8 display 4232 (that is, just the number).

Therefore there are certainly compatibility issues involved to get the best performance. I hope that someone with more knowledge can help.

Regards

Mark


Offline jong56

  • Newbie
  • *
  • Posts: 9
    • View Profile
Folks,

Ok, this is an old topic but as the server I wrote for the NE64 about 4 years ago does as has been described in this topic, I figured I would describe how it is down...obviously without and Ajax, et al processing.  If I repeat something from this topic here, I apologize.

Specifically, one can place more than one page in a page's HTML.  For the purpose here, the second complete page is placed at the bottom something like this:

</form>
<form name="Comm" method="get" target="Comm">
<input type="hidden" value="0" name="Start1">
</form></body>
</html>

Now as one can see, it is hidden.  So my server and pages perform a constant heartbeat to our device to make sure to the page that the server is still there.  On the server side, this allows the server to close the session if the heartbeat is not received. 

The is also used so that we never refresh any page after it has been presented.  I did not have enough RAM space on the NE64 for the largest IP packet possible so the page presentation was slow.  The background updates are fast though since the page is not refreshed and the only stuff passed back/forth is thr request as usual and then just the data change for the response.

Each page has a script to handle the hidden page response, which basically calls the same script that processes the page's original data values and updates the form.  Also some of the pages actually do not populate any fields from the base page's HTML but rather call the hidden page to send the data to populate the primary page with.  This model speeds up the presentation as my server does not handle dual-sends per browser ACK or parallel connections/requests as uTasker does very nicely.

The server just knows how to handle this special page by its name/action set.  It does the processing/data update and sends back the hidden page.

That's it.

Of course it is the responsibility of the server to handle all this in the fashion desired.  One other item helped in that the primary origin page name is included in the request made for the hidden page so that the server knows what to do for that page.  Otherwise, all of the page processing on my server is handled by the same code.

In any case, I am in the process of implementing this in uTasker v1.4 and will let you know.  As far as I can see, it should work as long as I can inhibit any std processing that might get in the way.  At this point i have not seen any, but I have not gone super deep into this.

To all, take care.

                                                  - jon  :D

Offline jong56

  • Newbie
  • *
  • Posts: 9
    • View Profile
Folks,

One thing I forgot was the page itself.  Here is an idea of how it can be done and will work with what I described in the previous post:

<script language="javascript">window.parent.handleResponse(error indication or other flag/value here,"PagNameHere","data vales to process here")</script>

That is the entire page.  The returned indicator is optional.  The page name in this page allows for the base page to have a script to handle say all base pages and populate accordingly.  Please understand that the only real important thing here is that the returned hidden page script here must call the parent for the proper processing to occur.

Once again hope this is useful.

Take care.

                                               - jon  :D