On Ajax and web development

The very basic idea behind ajax, to put it as layman as possible, is to be able to yet issue another http request, without reloading the whole page. Using a firebug console to peek into whats going on under the hood, we can see what our page tried to submit to this request, and view the relying responses. My questions therefore are:

  1. How can we tell if the logs on the console did originated on our page? Or does it log anything that is running asynchronously?
  2. Is it possible to setup a web server to, say, respond to all active connections and throw them html/json data without them requesting it? Rephrase, if someone requested the homepage, and while they are viewing its contents, could the server tell who are currently connected and send them responses, without the users initiating ajax?

The reason for this came from the topic of how some bidding sites work. Lets use beezid. com as an example.

AFAIK, AJAX still has the “same domain” restriction. So how much do you trust your browser?

A Response HTTP Header or more, of one type or another, is (almost?) always sent.

I Imagine there must be a way to send one or more of your own too.

i.e. If a page is generated from a PHP file I can send other specific Headers along using the PHP function.

Other times I need fancier htaccess stuff.

Off Topic:

eva bevo convert2media scam

Hey Mittineague, good to know your still active here!

My brain still isnt in the zone, but as far as I can tell, your also not sure about the problem. Let me bring up a similar scenario it it would help.

Lets say you requested a page, sort of like a chat application. You stare onto that page long after it has completed loading. After a few seconds, suddenly a message pops out.

My question now is, how did this happen? I assume its not reliable to regularly send ajax request to look for new chat messages. I was thinking if there is any way, that upon a specific event, I could ask my server to send another http response to all currently active connections, without the browser requesting them. Therefore, new chat messages will only be receive if there is any new ones, eliminating unnecessary ajax request from the browser.

Is there any way to do this?

I don’t think files can initiate contact with a page. The page will need to check something from time to time.

It doesn’t need to be a lengthy Response for “nothing new yet”, maybe even a pseudo-Boolean (single character string) - 0 or 1?

Hmmm, I understand. Actually, I have the same conclusion. My purpose in asking really is that there may be similar new technologies I’m not aware of that might be useful.

What your implying my a boolean response, is that the chatroom setup will be using some sort of storage, a database perhaps, so we have a place to check for available responses. This is the traditional way I think, but there’s something I’ve encountered over the last couple of days which might be useful.

This NodeJS could be used to listen to events on the server side, such that it could react to connection events. Since it can detect connections, its easy to send a reply to all active connections, but thats where I have a problem. How can a server send a text/html response to a browser without the browser initially requesting? Do you have any experience with this sort of scenario?