How are facebook updates received - ajax

When I use facebook, If someone posts a new status or a comment or whatever new content, I receive the updates on my facebook homepage without having to refresh it. How does that work ??

Likely they use a javascript timer which periodically performs an Ajax request and updates the page in the browser when something was posted.
wikipedia entry on Ajax

i'm not sure what they use, but i think they probally using node.js (http://nodejs.org/) which is like ajax, but not ajax. it listens to webSockets which is very cool.

Related

Is running an ajax request every second bad?

I am currently trying to create a chat function and notifications function on my site that would get the current users logged in and notifications periodically from a mysql database and right now I have it set to do an ajax call every second to a php page which returns the users online and notifications back in a json object. I am just trying to make sure there isn't a better way of doing this that I can't think of. Also is doing an ajax call to my server so often bad? I would really appreciate any insight on this. Thanks in advance!
As long as you have a hand full of chatters: no. It is not the best design, but it will do the trick. If you are looking for scalable techniques look for Comet or Web Sockets.

Ajax Server-Side synchronized HTTP request?

I am building a website which has a cron job that generates a file to the hard drive regularly. However, the timing of this generation is not precise and I would like it to be loaded as soon as it is generated by the browsers of my visitors.
Is there a nice way to make my server notify my visitor's browser to reload the page?
Other way around is quite heavy :(
Thanks!!
you should read about Comet, Comet allows you the receive "Push" from server-side to your client-side.
Eg,. thats the way how facebook chat works..
Take a look,
http://en.wikipedia.org/wiki/Comet_(programming)

AJAX on mobile website

I have a mobile website and I want to track clicks via javascript/ajax.
I thought I could use jquery to send the the tracking information and when I get a successful return I can redirect the user appropriately. I could do this no problem but I don't want to use jquery as it's a small webpage, loading in a JS library seems over the top.
What's the best way to post a http request? It needs to work on all modern smart phone web browsers.
Cheers
jquery-1.7.2.min.js is only 93kb and has all XHR functionality pre rolled and should work in all browsers.
Otherwise you would need to hand bake your own XHR's and take browsers into consideration
for example FF, Chrome and Safari can fire up new XMLHttpRequest objects, but IE will need a new ActiveXObject("Microsoft.XMLHTTP")

how to send some message to the users when now is looking my site's web page

how to send this messages to many people who looking my site on google app engine
1.using html5 ?
2.using ajax ?
thanks
Some technologies you can use for this include COMET (Ajax Push), Hidden IFrame (basically make the page never terminate and just send more data as it becomes available so the socket is never closed), html5 and websockets, or plain old fashioned XmlHttpRequest (some sort of polling mechanism as described by mirthlab).
You could set up an ajax poller to poll the server for the message and then display it.
Your question is a little unclear though. What will the message be used for. Does it have to show up without the user refreshing the page? Etc.

Does a website link (href) validation service exist?

I am looking for a web service kind of like Google Analytics.
Paste some javascript into your web page and if any of the links there become invalid, hey presto, an email is sent to someone telling them which link, which page etc etc has the incorrect link.
Anyone heard of such a service?
This would slow the page loading down a lot if it had to check for broken links every time someone visited it (basically a http request for every link). Not that it isn't possible, but the implementation would have to be very very good.
Javascript cannot send emails, you would have to use ajax to post the details to another page that would then email the admin. As this is all client side, it is very open to abuse.
I would suggest using a program to do it every now and again. There are even Firefox extensions to do it rather than a program. Google will also list a whole host of websites offering the service.

Resources