JQuery for Rich AJAX experience
To create a rich AJAX experience for a web site, similar to how the http://www.pageflakes.com/ loads different content re开发者_如何学编程gions dynamically, I was considering using JQuery to do this, using the load method to load specific regions of the page dynamically and append the content to the page.
From an implementation perspective, is this a good approach, as to using a web service to load data and build the UI on the page. I can see the pros/cons of using load being:
PROS
- Can let the server do the work, and render the UI.
- Can load only a partial of the document if needed.
CONS
- Web Service/client-building can be faster.
- Have to worry about form posting and server-side constructs or lifecycle (such as with ASP.NET or other technologies).
- Not necessarily as unobtrusive as other approaches.
Any other thoughts, ideas? Is using load in this way a good approach or not?
Thanks.
Pros:
- You get to put a shiny 2.0 label on your resume/site
Cons:
- It isn't search engine friendly. Without extra work, your content will never be indexed
- It is more work. It will take you longer to build the application
- Breaks the back button. Very annoying unless you write code to handle it.
- It can be slower. On older machines/browsers, running lots of dom manipulating javascript will be much slower than just rendering a page.
I think it is good to use jQuery to load parts of the page this way.
Advantage: The initial page loads faster, so any static content is quicker available. And the loading is more visual to the user.
Disadvantage: It might confuse the user to see an empty page build up this way, especially because the loading of a block causes the other blocks to move.
It is especially useful to use jQuery to reload portions of the page. In this case, all blocks are different and will probably require different reload intervals. News items might change every minute, but the weather won't.
Also, this approach is useful to load content from different pages.
If all the information comes from the same server/site, I'd suggest you load the initial page in one piece, and only use jQuery to refresh the parts on given intervals.
精彩评论