How to organize in a separate stream periodic pollings through AJAX?


JavaScript as against Java has no built - in support of job with streams. JavaScript functions are caused, when there is some event on page, for example, loading of page, click of the mouse, reception of focus by an element of the form. But you can use the timer with the help of a call setTimeout (), having passed as arguments a name of function to which this timer is connected, and time of a delay in milliseconds. Then you can organize a cycle, causing the same function as it is shown in an example below:



function checkForMessage () {

// To begin AJAX-interaction with use processCallback () as callback-function

}


// callback for search

function processCallback () {


// To execute actions after processing search


setTimeout (" checkForMessage () ", 10000);

}


Notice, that in the resulted example the cyclic call of function checkForMessage () will proceed indefinitely.

It is possible to change an interval of the timer depending on activity on page or other conditions. Besides it is possible to add a logic condition to interrupt a cycle, for example, by results of processing the AJAX-answer.


External and internal spaces of blocks, different interpretation

PADDING-BOTTOM: 0px;

PADDING-LEFT: 0px;

PADDING-RIGHT: 0px;

PADDING-TOP: 0px;


This description of internal spaces of the block - that distance which will be between a framework of the block and contents. Almost so we wrote and in BODY to begin page from edge{territory} of the screen.



margin-bottom: 5px; margin-left: 5px;

margin-right: 5px; margin-top: 5px;


This description of external spaces of the block - all this is strongly similar on CELLPADDING and CELLSPACING in the description of the table.


In what you will set spaces - your private affair. It is possible to apply percent{interests}, it is possible piksely, it is possible other units accepted in CSS.



The shorthand description


margin: 12px 12px 12px 12px; describes the top, right, bottom, left external spaces.

margin: 12px 12px 12px; describes the top, left and right, bottom spaces.

margin: 12px 12px; describes the top both bottom and right and left spaces.

margin: 12px; all external spaces on 12px.

Precisely also internal spaces enter the name also.


Now about " a difference of perception{recognition} ". We shall assume, we have set width of the block in 300 pixels, have inserted into the block "kuchku" the text, we look a result aga, very well, only the text closely adjoins to a framework of our block. It is necessary to correct. We do{make} it simply in the description of the block we add: padding: 50px; we Open the Explorer, we look all to us it is pleasant, all in the way. Now we open Opera5 or Netskejp6. ?-«-«!. Something "has carried" our block! Such young, and such thick... From what it...


If you will do all how is described by me, postavte 300 pixels are higher a page than the block the table in width in the same. Have put? All have understood? If no I explain. The explorer has taken our block, has driven in him{it} on 50 piksel spaces from each party{side}, thus having pressed down width of text area up to 200 and, pleased, on it has calmed down.


What have made the Opera with a Netscape? They have left width of a text field without change and have added from each party{side} on 50 piksel, in result all our block "has added" superfluous one hundred in width. The most interesting, that they in it are right! And it is necessary to act according to the accepted standards. It is that case, in which Explorer "oblazhalsja". Speak, a new sixth Explorer also "lazhaetsja".


Us, the truth, it should not disturb, at us the problems suffice. What to do{make}? There are two variants. The first to bypass a mistake, the second to correct her{it} by own strength.


On this site I am simple " uphill have not gone ". And what for? If we cannot freely use an internal space of "box" we can apply an external space to contents. We register margin: 50px; for the paragraph of the text which will be in our cell and we clean{remove} padding: 50px; from the description of the block. All works.


For the information{inquiry}. The width of all container is equal: the left external space + width of the left framework + width of the left internal space + width of contents + width of the right internal space + width of the right framework + width of the right external space. About methods of a "power"{"force"} output{exit} from the given situation we shall talk in the future.