I want to load more images in my website when I reach the bottom of my page. I'm using php and postgresql as my database.
For this post I simply load some text instead of image. I can write the code for it's equivalent.
So currently, I'm using a button at the bottom of my page, which when pressed re-loads the page and gives you more images(I'm displaying 50 images at a time).
But there are 2 problems with it, one being that the user will have to press the button again and again while I want it to happen automatically.
And the second one being that when new images are loaded, the previous ones are gone. I don't want to happen. For eg., if currently 1-50 images are present, my page later changes it to 51-100 while I want it to have all 1-100. I'm unable to solve this.
Please help. Thanks!
What you are looking for is commonly referred to as "infinite scroll pagination", while what you're asking for is techniclly possible using only PHP it would be a terrible user experience, as each reload would take the user to the top, and they would constantly have to continuously scroll further and further just to reach the location they were previously at.
Alternatively, handle this with JavaScript, an example: https://infinite-scroll.com/demo/full-page.
Doing simple Google searches reveals a plethora of options for JavaScript and JQuery plugins to achieve this.
An alternative, without the need for a plugin you can implement the answer to this:infinite-scroll jquery plugin
Simply call your PHP code in the form of an AJAX request when the bottom of the page is reached and append your new results. (this could be easily achieved with vanilla javascript as well).
Hope this helps.
Related
I'm building a site where there will be four tiles on the front page. When a tile is selected, I want the content to pop up in like a window that will be a bit transparent so you can see the main page behind it.
I've successfully coded just that, getting the link to bring up another div that is otherwise hidden and I've even gotten it to load another html document. I accomplished this with XMLHttpRequest();. My question is, is there a more efficient way to do this? I know I've done something similar in PHP before in school and when I google, I do see that being a way to do it, but I'm also seeing jQuery and AJAX being mentioned. My overall goal is to get it to where if I want to update the CSS of the screens, that I only have to do that for the main page, and it affects the content pop-ups.
I hope I explained this well enough. Thank you for any advice!
It's very simple to do in jQuery:
$("#yourDivsId").load("/UrlOfYourIntendedMarkupDelivery?anyarguments=true");
I need to create a website with an audio player that plays as users traverse through the site. At the same time, the content section needs to fade out and back in while this is still going on. So bring in another piece of HTML without reloading the page. The question I have is, how can i get all those to run correctly, while at the same time, running different Jquery plugins on different pages?
Essentially, I need to website to run like this one but with a continuous audio player in the corner or something.
http://www.chalicerecording.com/
If you notice, the page never reloads and the name of the actual file doesnt display on the browser top. This gives me the idea thats its using PHP for the page.
So with that idea, I ended up finding this.
http://www.youtube.com/watch?v=ytKc0QsVRY4
The problem im having with that is that I cant seem to figure out a way to run individual Jquery plugins on each individual PHP page without reloading the entire page. I hope this is enough info for you guys to work with.
you will need to use ajax calls to do so
jQuery.ajax
jQuery.post
jQuery.get
you also need to use jQuery fadeIn , jQuery fadeOut
Can someone tell me how to write code that pushes the content of a finished webpage down half an inch or so, then loads an ad across the top of the page, like this example:
http://abcnews.go.com/International/hideouts-sacred-spaces-experts-baffled-mysterious-underground-chambers/story?id=14136379
(example may no longer be showing this ad/function)
The entire page loads, then gets pushed down, then the ad loads at the top of the page. My code for this would be at/near the bottom of my clients html.
The ad content will come from a different server.
The same code would ideally work with all/most finished websites instead of being specifically tailored for each one.
Thanks for any and all help.
I suppose you implement your ads in your HTML by using a static code (eg. when you're using Google Ads). When you put this code on top of your page, it'll show the ad on top of your page. Optionally, you can style it a bit so it's centered.
Since you load your ads from a different server, I don't see any reason why the HTML-code behind those ads is dynamic (I don't know if it is?). Your ad-provider will take care of showing the ads in a random-order.
If you'd looked at the source of the page you'd see this this is achieved using JavaScript, not PHP. If you want it to happen (seemingly) after the page loads you need to write some php to inculde the html/JavaScript/images whatever for the ad, then some JavaScript to dispay it once the page has finished loading. Or use AJAX to dynamically modify the DOM.
Check out the jQuery JavaScript framework.
I would prefer to use a front-end code like jquery or normal javascript, and prepend your ad to the body.
OR
If you want to do it with a server-side language. You can add the server variable just after the opening body tag, and populate the html to the variable via server-side code.
See my example:
Gray : body tag
Green : your website
Red : the ad section
If you don't have a wrapper container around your div, add one. And use the methods I mentioned above to prepend the ad to your site.
Hey there, I'm trying to create a way of when a link is clicked in my flash movie (that is embedded in html) its counted and added to a "database" so I can keep track of the hits. Bearing in mind i've got 23 different links so I need a separate count for all 23.
Thanks - Caius
you have a few options, but frankly, I don't see how JQuery fits in.
Option 1: Use third party analytics software like Google Ananlytics
You can call the GA hooks in your swf to trigger specific content views, or you can use javascript to update the browsers anchor location ( http://mysite.com#link1, http://mysite.com#link2, etc...)
Option 2: Roll your own simple tracker
When the user clicks on a trackable item in your swf, call a script on your server that updates your database. a simple PHP script could handle that.
cheers.
I need to include the content, scripts, forms and dynamic abilities of one page in another onClick.
Take a look at http://www.divethegap.com/scuba-diving-programmes-dive-the-gap/dahab-master-scuba-diver.html
Then follow one of the links that says 'Beginner' 'Open Water Diver' etc....
You will find a PHP page with a series of options. It is an adaption of the wordpress blog system to produce only specific options for specific programmes by considering each type of each diving programme a category and then displaying only results from that category.
You will see that each option is also a collapsible panel and there are also several javascripts that calculate durations, quantities and prices. There is also a validating webform at the end.
Now go back to the first page. What I would like to do is include all the content from the second page after the main header inside tabbed panels on the first page so that the customers can immidietly see everything that is included. Essentially the options on the first page would become a series of tabs.
The only way I can see to do this is with an iFrame as each option would need a unique URL ending (that is .php?cat=26 or .php?cat=27). THe problem is that the collapsible panels will not work with an iFrame as the iFrame will not resize when the panels open. There were also some calculation problems, but I think that was more down to me staring at the screen for the last 3 hours not remembering to include everything.
I have tried it with resizing iframe SSI scripts and have got nowhere.
I tried actually embedding it in the page better with a ajax script, but that left behind all the scripts that make it work. I checked with full URL's on everything and it would not take work with any scripts.
I know that you could just make the whole page reload but then the user would be at the top of the page again, and even if another script was applied to slowly bring them down again it would not be anything near as easy to use as if it was like tabbed panels.
Any ideas.
Kind Regards,
Definitely no need for iframes. AJAX will do the trick here.
Here's a link with a demo + code:
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm