On the Stack Overflow site, we can see following updates asynchronously.
Reputation Changes
New question added in question list
New comment added, etc.
As per my understanding, it can be done in XMLHttpRequest (XHR) request asynchronously, maybe with the help of setInterval.
Confusions: In Firefox, no XHR request is coming and even then I can see the above changes asynchronously.
Which kind of implementation is this and how can this be done in ASP.NET MVC?
This impressive and beautiful stuff is asynchronous calls made from the client to the server using Ajax.
A very simple approach is to use jQuery Ajax to make an asynchronous call inside a setInterval to search for "updates" of a question (this is the question with ID 17779628. We can see on the URL =P). So, the call to the server can pass this ID and a TimeStamp (a date) of the last call made to the server. The server then brings updates that occurred from TimeStamp to DateTime.Now.
I am not sure about the real implementation of Stack Overflow, but I already did a lot of stuff just like this.
Another tip:
There is an improvement. ;)
Modern browsers contains implementations of WebSocket. Since sockets are "peer-to-peer" and not "client-server", modern browsers don't need the approach with setInterval. Instead, you can implement a WebSocket opening in JavaScript and then the server can send the updates actively in the moment that it happens (you can use design patterns that include events).
Take a look at CanIUse to see which browsers supports WebSocket.
EDIT
Anyway, I just opened the code for you. The Stack Overflow's JavaScript code uses a singleton design pattern for the JavaScript code. Just take a look at the StackExchange variable in your browser console. That is the heart of the JavaScript code here. As you can see, there is a whole API built upon this StackExchange variable. Now, search for StackExchange.realtime.init('sockets.ny.stackexchange.com:80');
Then, take a look at the implementation of StackExchange.realtime.init at your console. It seems that they support asynchronous updates with WebSocket. This is nice and modern, but only supported by new browser versions. If you need to maintain backward compatibility, you can support both WebSocket (for new) and an Ajax implementation (for old browsers).
I imagine they would be using something like SignalR or WebSocket. SignalR will take advantage of WebSocket when available and then fall back to a number of other techniques to achieve the same thing.
I answered a similar question recently:
How do I display real-time information to the user?
As Nathan Fisher said, you'll want to look into Websockets and SignalR.
With regards to you not seeing XHR requests in Firefox, try looking for Websockets instead. In Chrome, I can see a Websocket on every SO page I go to.
Notice that is is dealing with information regarding my inbox, my reputation and also while I was writing this answer Nathan Fisher made an edit to his post, so I can see that the page is dealing with that also (I saw "An edit has been made to this post").
Related
I want to put an information in a webpage recurrently by a cron task (or whatever else), each week, but not on my webpage !
For example : value of gold on a trading website, take it every Monday, is it possible ? (I don't want to do that but something similar, the principle is the same)
From your comment, I guess that you actually want to download data from a web page as a source.
You don't specify which language you are working in but I've personally had some success doing this in .NET using a WebClient.
There is more information about the WebClient here but I think to make better use of StackOverflow, you'd be better trying to tighten up your question to include more specifics.
What I am trying to do is allow users to making postings to Craiglist through my own website using PHP curl. This is NOT an automated posting system, I just want users to be able to post onto Craigslist and my website at the same time. So far, I've managed to log in using php but I'm still not sure how to post the title, description, contact information, etc. I am not familiar with cURL.
Your question is kind of broad, so I'll answer broadly. Narrow down your question (or post a follow-up) so we can help you better.
Is it possible to making a posting to Craigslist through my own website?
It depends, there are two major ways, but most websites block these so I suspect Craigslist does too.
1. Clientside
Your visitors become visitors of craigslist.
You take the form that you find on craigslist, and host it (the html code) on your site, but with the form 'action' pointed to theirs.
They'll probably block these, based on the REFERER, a session key or something alike.
2. Serverside
Your server acts as a client for Craigslist.
You host the form on your server, and the processing page as well. After you've captured all the input, your server will now act as a client to Craigslist, using indeed for example php curl.
You should try if 1 works, if not, start coding on 2. If you're stuck in a specific part, post a question and we'll help you further.
There is an API available now to make automated posts (one or more) in one request.
http://www.craigslist.org/about/bulk_posting_interface
There are two caveats in your case:
It uses RSS as the request/reponse.
Your users will need to provide their Craigslist user/pass (assuming they have an account).
For an event in a couple of weeks I'd like to make an web page/app which display tweets from a specific user, a specific hashtag and all #reply's at the first user in 3 boxes on the screen.
However I've never tried this. I want to use either .NET (C#) or HTML/CSS/JS since I'm proficient in those. Are there any libraries/API's I can use? Or is there an readily available freeware/open-source app I can use?
Have you seen TweetSharp?
Use Twitter's profile and search widgets. Profile for the first box, a search of the hash tag for the second box, and a search of to:username for the third box.
I actually just posted this as an answer to another question:
I just updated a plugin to work with the Twitter 1.1 API. Unfortunately, per Twitter's urging, you will have to perform the actual request from server-side code. However, you can pass the response to the plugin and it will take care of the rest. I don't know what framework you are running, but I have already added sample code for making the request in C#, and will be adding sample code for PHP, shortly.
The plugin makes a call to statuses/user_timeline, but you will likely want to look at statuses/filter or statuses/search, instead. All you will have to do is add your desired parameters (hashtag, replies, etc.) to the server-side code and it should work (with the addition of your security keys and tokens, of course).
Good luck! :)
Can anyone please recommend any good Load Testing software?
I have a website which updates scores every minute via ajax calls and need a load testing software which supports ajax calls (javascript) too!
This is a pretty broad question that depends greatly on exactly what you want to test and how you define "good" software. Many people will say you can't load test AJAX based sites using HTTP-simulation tools. We do it every day, so I can tell you that isn't true. However, the difficulty of the task varies greatly depending on the testing software you choose and the complexity of the site and scenarios you are testing.
My recommendation is to pick a few tools within your price range and evaluate how well they work for your particular scenario. If they have good support, you should contact them with any difficulties. If they can't get you going in short order, move on to the next product.
(Disclaimer: I work for Web Performance - our Load Tester product handles most AJAX scenarios just fine - which may be why we're on the first google page for "ajax load testing").
Ajax is just an HTTP call, so you have many options.
I can recommend WebLOAD.
Works well with Ajax. The script is written in JavaScript, which is a plus.
Although I cant recommend an AJAX load testing utility I can however recommend an alternative to normal AJAX calls to me it sounds like what you need is APE (Ajax Push Engine).
So instead if your application spawn repeatedly contacting the server
Your App -> Do you have a message for me server?..
Server -> No..
repeat X 10 Ajax Calls until Server -> Yes!
What APE does it pushes the data/information directly to your users browser without
the application contacting the server. Think of it this way, the server "shouts" a message and your web apps then receive this message and interprets it. This concepts is known as long polling.
APE is pretty darn fast and not that difficult to implement.
Heres a link to the APE project - http://ape-project.org
Theres a few guys that have some excellent examples available on the Internet,
heres a link to an interesting one which uses APE to create an SMS gateway.
http://www.ifc0nfig.com/esenape-send-and-receive-sms-in-real-time-using-ape-jquery-php-and-libape_controller/
I hope this interests you.
Regards
Trying to parse/scrape the course site for memphis. The site is "https://spectrumssb2.memphis.edu/pls/PROD/bwckgens.p_proc_term_date". It appears to be some sort of javascript issue, or dynamic generation of the text. I can see the underlying DOM structure using livehttpdheaders/Firefox, but not when I simply view the underlying source/text of the page..
Thoughts/Comments/Pointers would be appreciated...
Well this modern days the site may be assembled in few steps. First the main structure is pulled in and then, often based on identity of the user additional AJAX calls are executed. Your best bet is to sniff HTTP to see what kind of requests are issued between the site is initially requested and when it's fully built
Since you are using firebug you can get HttpFox add-on which gives you what you need