/    Sign up×
Community /Pin to ProfileBookmark

ajax questions (repost)

Hi,
1) Can any one tell me how can we prevent problems caused by pressing browser back button while your site is ajax based?

2) Which is the best call to get HUGE ( 300k + ) text through Ajax ? It mostly gets only some starting part of text.

Thanks

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@UltimaterNov 12.2006 — 
  • 1. Cookies can be used to rebuild the page the user had prior to hitting the back-button. Since cookies can be disabled, you might also try using JavaScript to save the data in a static text field (a field that wasn't created via JavaScript) that will retain it's value when the user navigates from page to page. Best to encode your data with encodeURI or escape and use decodeURI or unescape to restore the encoding back to the original data. With the encoded data, you can save it in an INPUT TYPE=HIDDEN.


  • 2. Try breaking the file into smaller packets and use a few Requests and piece it together client-side so the browser doesn't run slow and so that the HTTP request will not be terminated due to lag. Also there should be no reason to load such a big file client-side. It may be best to re-write the system to keep the data server-side and obtain the needed information at run-time as needed and make a seperate HTTP Request for each such-trigger. Also unless the data is guaranteed to be unique between any two given requests from the same user, you may want to cache the data on the user's computer. One of the problems with cached data is that when it changes to tell the browser that it's version of the cached data is old and it must get the new version. The best way to accomplish this is to force the browser to obtain the new version by adding the time that the data was last changed to the URL. i.e. xmldata.php?lastchanged=1163367453

    Then when the lastchanged time changes, it will cause the browser to consider the link a totally new link and it will cache the new version etc.
  • Copy linkTweet thisAlerts:
    @mrizwanauthorNov 12.2006 — Thanks for your reply.

    1) can you please explain your point one a little more?

    2) some times loading large data becomes necessary ... like gmail when a users opens a mail huge emails are loaded without page refresh. while a simple xml http call will not allow to read that much data through server using ajax.

    any suggestions?
    ×

    Success!

    Help @mrizwan spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.16,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @nearjob,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,
    )...