How can I put a JavaScript variable into a SESSION so that I can use it for pagination?
I've got a site that I need to change the number of viewable items on the screen depending on the size of the screen. So it's a gallery that will only show as many items as will fit on the screen.
So I've got pagination set up. I can also get my javascript / jquery to determine the number of images that can be shown on each page based on the size of the screen. The problem I'm having is I don't know how to pass that information back into my PHP so that I can then change the number of results I want pulled for each page in the pagination.
My thought was to get the sizes and do all the math javascript / jquery at the very beginning then pass that data into a session variable so that it can easily be gotten and used in my queries, but I can't figure out how to get my sizes into the SESSION.
My thought was to use:
$.post('php_file_that_posts_to_session.php', { variables: 'sizes to pass'});
that didn't seem to work however. At least when i try to echo the session variab开发者_如何学JAVAle I don't get anything.
Any suggestions?
In Jquery you can use the method Data To store any info in dom element. jQuery.data()
http://api.jquery.com/jQuery.data/
"The jQuery.data() method allows us to attach data of any type to DOM elements"
精彩评论