views:

83

answers:

1

I am trying to take data to one page from another. The problem is here is, data may be too long and divided into multiple pages. When the user clicks on 1, 2, 3, ... links he is redirected to the other page. However, I want data to be reloaded on the same page. With SLaks's suggestions I came up with the following code but it is not working at the moment.

$('ul.thumbs li.pagination a').live('click', function() { var pageNumber = parseInt($(this).text().replace(/[^0-9]/g, ''));

$(function ViewImages() {
    $.ajax({
        type: "GET",
        url: "images.cs.asp?Process=ViewImages&PAGEID=" + pageNumber,
        success: function(data) {
            $("#ViewImages").html(data);
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            $("#ViewImages").html('.');
        }
    });
});

return false;

});

A: 

You can use jQuery to intercept the links, like this:

$('ul.thumbs li.pagination a').live('click', function() { 
    var pageNumber = parseInt($(this).text().replace(/[^0-9]/g, ''));
    //Load page
    return false;
});
SLaks
Of the two pages, in which page should I use this code?
zurna
This code should go in the outer page. (The one that calls `$.ajax`)
SLaks
I forgot to add `return false` to the end of the handler.
SLaks
Still not working and still no errors.
zurna
Your selector is wrong. (There are no `a` elements of class `pager`) Yo need to change it to `$('ul.thumbs li.pagination a').live`
SLaks
I was trying something else. Please take a look again.
zurna
You need to replace the `//Load page` comment with code that loads the page.
SLaks
Can you please check my original message. I edited as you suggested but still not working?
zurna
SLaks
zurna