ajax based webpage - good way to do it?

I build a website focussing on loading only data that has to be loaded. I've build an example here and would like to know if this is a good way to build a wegpage. There are some problems when building a site like that, e.g. - bookmarking - going back and forth in - history SEO (since the content is basically not really connected) so here is the example: index.html Somebodys Website
pagecode.js var http = null; $(document).ready(function() { // create XMLHttpRequest try { http = new XMLHttpRequest(); } catch(e){ try{ http = new ActiveXObject("MS2XML.XMLHTTP"); } catch(e){ http = new ActiveXObject("Microsoft.XMLHTTP"); } } // set navigation click events $('.nav').click(function(e) { loadPage(e); }); }); function loadPage(e){ // e.g. "link_Welcome" becomes "Welcome.html" var page = e.currentTarget.id.slice(5) + ".html"; http.open("POST", page); http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); http.setRequestHeader("Connection", "close"); http.onreadystatechange = function(){changeContent(e);}; http.send(null); } function changeContent(e){ if(http.readyState == 4){ // load page var response = http.responseText; $('#content')[0].innerHTML = response; } } Welcome.html Welcome
To this website.... So as you can see, I'm loading the content based on the IDs of the links in the navigation section. So to make the "Page1" navigation item linkable, i would have to create a "Page1.html" file with some content in it. Is this way of loading data for your web page very wrong? and if so, what is a better way to do it? thanks for your time EDIT: this was just a very short example and i'd like to say that for users with javascript disabled it is still possible to provide the whole page (additionally) in static form. e.g.
  • Welcome
  • and this Welcome.html would contain all the overhead of the basic index.html file. By doing so, the ajax using version of the page would be some kind of extra feature, wouldn't it?
    In short: Yes, building your complete website using Ajax is very, very wrong. The traditional way is still the best ;)

    以上就是ajax based webpage - good way to do it?的详细内容,更多请关注web前端其它相关文章!

    赞(0) 打赏
    未经允许不得转载:web前端首页 » jQuery 答疑

    评论 抢沙发

    • 昵称 (必填)
    • 邮箱 (必填)
    • 网址

    前端开发相关广告投放 更专业 更精准

    联系我们

    觉得文章有用就打赏一下文章作者

    支付宝扫一扫打赏

    微信扫一扫打赏