1

I'm not all the familiar with the .load functionality of jQuery, but it would be REALLY cool if I could do what's in the url.

Basically, I've got a PHP loop that cycles for 10 pieces of content per page. This is based on a Query String

http://domain.com/page/?offSet=0&rpp=10

will load the 10 most recent bits of content (rpp=10)

http://domain.com/page/?offSet=10&rpp=10

this loads the content 11-20 (notice offset=10). Offset 20 will produce 21-30, etc.

BASICALLY - I've got some links at the bottom that use PHP math to determine the current offset and add 10 or subtract 10.

Currently, they reload the whole page (gross). Can I use .load with the query strings to grab the container div with the other content?

3
  • 4
    yes.... you can? P.S. you should always try first before you ask... Just sayin Commented Aug 23, 2012 at 0:03
  • This is called pagination (or paging). Makes sense to return from the server just the number of results to display. Otherwise, download all as data and show only what you want (no secondary $.load() calls, though) on page "request". Commented Aug 23, 2012 at 0:08
  • Someone upvoted this - they might have wondered too. I didn't want to get too far into coding it just to realize it didn't work (every example I could find referenced an extensioned address domain.com/page.aspx etc. with no query string to boot. Figured I'd ask for those who want to know but don't know and spend all day on SO Commented Aug 23, 2012 at 0:09

1 Answer 1

1

Yes, you can do that. You can add a selector after your URL to indicate only what section of the loaded HTML that you want to insert into your current page's container.

For example:

$('#myGridOfData').load('/page/?offSet=10&rpp=10 #container');

Which will load only the contents of #container from your loaded resource into #myGridData.

See the jQuery API for more details.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.