trying to figure out how to best display a bunch of information on a "mother" page.
When I enter the first page, which is populated based on a GET method for a specific "id". on this page, I want to have an area where the user can click on either a link or button or other which will display a subsection in a single location. These pages will need to display the appropriate information based on data located on the page.
Would the best way just to be to create an iframe?
I'm unclear, as to how I best get this information to change appropriately (i'm still quite new to this process).
would I continue to use the GET method still on the "child" page; Do I also need to use a POST method somewhere?
any guidance would be great.
The better approach is to use ajax to populate that div.
Related
I have a database of different stores.
When a user clicks on a store name, I want an Ajax function to run displaying information about the store in a different div.
Information categories for all stores wll be the same: products carried, location, general information, etc.
I could easily make it so that each different store uses a different file name as an argument to the ajax function, and all files would have the same layout/format but with different data.
However i feel like this is bad form. How can i make it so that i have one fixed template and all that changes is the information specifics imputed into the template?
Please note that the store information display pages will also need to be able to have clickable links of their own (i.e. click on location and a google map pops up).
Is it something to do with XML? I dont know much about it.
Instead of returning a template, return the data.
So it says getstore.php?id=2 which returns a json string
{"name":"my store", "info" :"blah"}
Then you use java script to insert a new div, populated with that data.
I am looking to build a single page with 1000+ pages, dynamically generated from a database. One row in the db = 1 page.
I'd like the navigation to load a different, initially hidden with jQuery, and I believe I'll be ok doing so, however I'm also hoping for each individual post/div to be accessible with a direct URL, for example site.com/page.php?page=1
Is there a way to make the url change onclick, along with the div? This way, if I had a facebook share button, it would actually share a specific post, and not just the same static page.
Thanks!
You can use the jQuery plugin BBQ http://benalman.com/projects/jquery-bbq-plugin/
I want to make a webpage where an user can add the title from a book he has read. These changes are reflected in real time on a list that contains all books he has introduced on the database, without the need to press any "reload" button. By example: there is no need to refresh (F5) the page to see the last book added.
I don't know if I can do this in PHP or in any other language, so I would like to know which is the best suited for something like this.
Thank you.
I think you are looking for Ajax. Would be able to asynchronously update the section of the page (the post in this case) without the need for page refresh.
You will want to do this with javascript, using the onchange event, and for a discussion on this you can look at: Call Javascript onchange event by programatically changing textbox value.
Basically, you react to the data being changed, then just send it immediately over using ajax to the server, but, you need to be aware of two things.
First, how will you handle errors, such as there is no book with that title, or the length is too long. I tend to put the error message in or by the place where they had the bad data.
The other is that you need to pass back the id when the data was inserted, so that when they change it again you can just do an update, so you will need to store that. I tend to put the database id I need in the element id, but you can keep it in an array in javascript, since it will maintain state for you.
What I have is a search form that submits to the same page and it fetches the results using an AJAX request.
This uses the POST method and I am trying to figure out a way to try and do something along the lines of having a button to open this page in a new window to preserve the search parameters and results and to allow it to be bookmarkable somehow but I can't really think how to do this.
The other main reason for doing this is because the search results contain links to if a user clicks one and then clicks back all the form parameters are lost, I have worked around this by having the links open in a new window.
Any help, advice and opinions would be much appreciated.
If you do a GET method instead of POST, then the user will get to an URL with its form parameters in it.
It won't have to be ajax anymore
I'm looking to create a multi page ordering form the first page would contain some dropdown and text fields, the second page would contain more text fields, the third page would be an order summery with paypal payment option.
I'm just wondering what the best way to create this order form is. I've used sessions in the past but never with users entering in text and picking items from drop downs, does anyone have any resources for doing this? Or does anyone know of a jquery or other ajax example or plugin I might be able to use and modify.
any insight would be a big help.
thanks
The simplest technique might be to use hidden form fields to carry fields from previous screens through to the final screen.
Just make sure you validate all the values when the final screen is submitted to make sure that the user hasn't twiddled the data.
You don't need to do pagination at all if you don't won't to. Just use css to show/hide the "pages". It doesn't sound like you have to save the "state" at any point.
But if you want to do multiple pages, use a session or a cookie to track the user. Then save the data to a database a mark it as incomplete. On the final page, retrieve it all and show it on the page. The server can't tell if a request is ajax or not, so it doesn't matter what you use for submission.