in Education by
I need to work with an ajax powered web page so I can pass an id or ids in the URL and it'll only display result(s) based on the id(ids) passed in. For an old cgi page, I could do: http://myurl?id=1, is there a way of doing this for Ajax pages? Thanks, David JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Simplest - use anchors and the hashchange event to modify the state of the URL (you'll mostly need a shiv for older browsers like IE 6 and 7). When the page first loads, parse the hash and load what you need to via ajax. (An example of library to help with that Ben Alman's jQuery bbq plugin.) Your URLs in this case will look like this: http://example.com/entry/point#/my/app%3Fq=1 Neater - use the new history API to pushState as the page changes for newer browsers and fallback on hashchange for browsers that don't support the new HTML5 goodness. (An example of a library that helps with that is Ben Lupton's History.js plugin). Your URLs for newer browsers will look like this: http://example.com/my/app?q=1 while URLs for browsers that don't support the new API will see the hashchange URL. Neatest - use a full routing or MVC framework and don't re-invent the wheel. Examples include, but are not limited to: JavascriptMVC Backbone.js Spine.js Crossroads.js Note that with the newer history API, you really should make sure that all of your URLs are actually reachable and usable without JavaScript. (So if you push http://example.com/my/app?q=1 onto the history stack you should be able to type that URL into your browser's address bar and just go there.)

Related questions

0 votes
    This question already has answers here: Set default home page via in JSF project (3 answers) Closed 5 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 8, 2022 in Education by JackTerrance
0 votes
    Each web page has its own website (URL) address.true or false Select the correct answer from above options...
asked Dec 2, 2021 in Education by JackTerrance
0 votes
    Explain differences between the page execution lifecycle of an ASP.NET page and an ASP.NET AJAX page?...
asked Dec 31, 2020 in Technology by JackTerrance
0 votes
    I want to dynamically create variables with dynamic names for later use in my transform, but to do this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 10, 2022 in Education by JackTerrance
0 votes
    I want to dynamically create variables with dynamic names for later use in my transform, but to do this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 8, 2022 in Education by JackTerrance
0 votes
    When I use ajax call from a modal window, the request url seems not correct. I have a webserver ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am using jquery ajax get. SO when my form is submitted it then submits to a php file but the ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 7, 2022 in Education by JackTerrance
0 votes
    I am using jquery ajax get. SO when my form is submitted it then submits to a php file but the ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I have an html select on my page $query = mysql_query("select * from results"); echo " "; while ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 11, 2022 in Education by JackTerrance
0 votes
    I have an html select on my page $query = mysql_query("select * from results"); echo " "; while ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    I have an html select on my page $query = mysql_query("select * from results"); echo " "; while ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    I'm using $.ajax() to load new pages on my site if certain conditions are met (a flash-based ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 4, 2022 in Education by JackTerrance
0 votes
    Which page directive should be used in JSP to generate a PDF page? (a) contentType (b) generatePdf (c) typePDF (d ... JSP & API of Java Select the correct answer from above options...
asked Feb 22, 2022 in Education by JackTerrance
0 votes
    numbers. 4. (a) When running a particular program with N memory accesses, a computer with a cache and paged ... the system ? cribe Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
...