SRL Archive - Web Development

passing dynamic gets with javascript for PHP to handle? or other method?


grats

2013-02-23 08:41:48

Hello, I want to pass very simple GET messages with javascript to PHP, that dynamically change as you click them (it is for a limit query)


anyway I want just like a button and it to send a get to have the pages expand further.. so like it shows 10 of something, and when you click the button it then shows 20 of something (so 10 more) and if it already shows 20, and you click it again, it now shows 30.. etc etc


http://imgur.com/

imgur does it kinda.. with just scrolling down, I'd prefer a button. or if there is a way to do it without having to send a $_GET?

I do have jquery included, so if you have some method that requires jQuery.. that is fine with me. Thanks to anyone that can help

Bobarkinator

2013-02-24 01:29:35

The easiest way to do this is to hit a php page with an ajax call ($.ajax from jQuery), you'll probably add the limit as a get parameter like you said, but I would only have it select 10 at a time. So if you already have the first 20 items, make it select 20-30 then send those back in the ajax response (probably best to JSON encode them) and use the javascript to parse and insert the items into the page. That would be the easiest way to do it in my opinion

grats

2013-02-24 15:12:37

From: Bobarkinator
The easiest way to do this is to hit a php page with an ajax call ($.ajax from jQuery), you'll probably add the limit as a get parameter like you said, but I would only have it select 10 at a time. So if you already have the first 20 items, make it select 20-30 then send those back in the ajax response (probably best to JSON encode them) and use the javascript to parse and insert the items into the page. That would be the easiest way to do it in my opinion


Is there any chance you can show me? I'm horrible with javascript, I know just some pretty basic type things and only ajax I ever did was to grab a mysql query php script to check if a user was already registered type thing.. and even then I copied part of it from stack overflow :P

I can send you a link to what I want to do and explain it better in PM if you can help out, thanks

Brandon

2013-02-25 18:08:23

From: grats
Is there any chance you can show me? I'm horrible with javascript, I know just some pretty basic type things and only ajax I ever did was to grab a mysql query php script to check if a user was already registered type thing.. and even then I copied part of it from stack overflow :P

I can send you a link to what I want to do and explain it better in PM if you can help out, thanks


http://www.9lessons.info/2009/07/load-data-while-scroll-with-jquery-php.html

Replace the scroll function with a button that invokes the last message function or a $("#ButtonID").click(…)

grats

2013-02-25 20:26:28

From: Brandon
http://www.9lessons.info/2009/07/load-data-while-scroll-with-jquery-php.html

Replace the scroll function with a button that invokes the last message function or a $("#ButtonID").click(…)


woo thank you so much, I'll check that out when I wake up

also totally forgot, youtube comments do exactly what I want to implement (looks like your link will help me do that)

can't believe I forgot about the youtube comments though, gave imgur as an example rofl

manisha

2019-03-19 01:54:21

Thanks for this information. It has helped my to work on my project.