0

I have a really weird question... Don't know if it possible to make, However although i know how to do it via old get urls and refreshing page, I want to try the new way with jquery to call the file and post or 'get' data via jquery but without using a form.

I will be using a <a> link, if you go to my website http://www.jonathansconstruction.com/gallery.php and you see the second gallery menu where it says view all, that will filter the category to view and hopefully show it in a div like it is showing at the moment, one div per category i used to use

<a href = "file.php?catfilter=category">aaa</a>

and on php side use a $_GET[];, so i will like to know a different way to pass the values to set category filter, and also, be able to menu "current" with jquery. By the way, the Menu will also be generated dynamically depending on the number of categories on the database..

Will also like to add a "twitter/fb" style pagination(load more data on scroll down or when user clicks show more) but will also like the divs to be grouped by category getting from the database. That's the whole idea, I do know how to setup the output and do a lot of the php side to group the items together, however, I'm not too sure about the new pagination style (used to use the one with pages to click next) and also how to run/post data to php without form and without refreshing.

Hope this was clear enough, if not let me know. Any help/idea on how to do it is appreciated. Thanks a lot

1
  • 1
    If you would love to have client side pagination then you can use this datatables.net . If you wish to have the server side then, make your own serverside pagination script or there are scripts for pagination. Commented May 26, 2012 at 5:32

2 Answers 2

1

To load data dynamically and that too without refreshing your page, for that you can use Jquery $ajax() method. Here is the link

http://api.jquery.com/jQuery.ajax/ to help you understand in detail

you can also pass parameters to the url/page you want to execute, and whatever is the result of your php file, you can set that to wherever you want

for example:

$.ajax({
  type: "POST",
  url: "file.php",
  data: { catfilter : "category" }
}).done(function( msg ) {
  $("#container").html(msg)
});

file.php

<?php
if(isset($_POST['catfilter']))
{
   //your code here
   echo "your code here";
}
?>

calling above jquery ajax method will set the output of file.php to html element with id= 'container'

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

Comments

0

without refreshing your page to load data you can use jQuery.Ajax


$.ajax(     
{   
    type: "POST"    
    url:page,
    data: {......}
    beforeSend: function(xhr) {
        $('#load').empty().html('Loading... ');
    },
    success: function(data) {
        $('#load').empty().html(data);
    },
    dataType: "html"    
});

the result will be displayed in div load and get from the url:page

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.