javascript - Best way to preserve data between 2 HTTP Request -
i have web application, has search form. user entered query string input field , submitted form using submit button. next, result page shows search result.
the result page has "endless scrolling" feature. means, when reaching end of page, results loaded. have send 2nd query search engine same query string.
currently, see following options:
1.) using session-parameter:
the first search request (coming search form) stores search parameters, including user's query string, in session storage , "endless scroll"-javascript function calls "search"- url without additional get-parameter
pro: no direct xss problems (?)
contra: users have explicit reset search/remove querystring session parameter doing action.
2.) echoing query string in result page:
during generation of search result page, user's query string rendered webpage. example in hidden field or javascript parameter. javascript can fetch query string , use query parameter or submit form using ajax.
pro: when re-entering page, no old search data loaded session store - it's more transparent user. no "reset-session-search-parameter" mechanism needed
contra: it's vulnerable xss, when html encoded... (?)
my questions: a.) these correct assumptions of pro , contra? b.) solve problem?
you have javascript on page if doing endless scrolling, following:
pass search query server page content, like:
<script type="application/json" id="current-filter"> {query: "search me"} </script> when scrolling evet triggered, read filter , send request:
var filter = json.parse(document.getelementbyid('current-filter').innerhtml); // send form
Comments
Post a Comment