success: function(data){
   $(this).parents('div.paginator').html(data); },
}

Can, you cannot use "this" within the callback.  But you could rewrite
your method like this:

function paginator_hook(){
   $('div.paginator a.ajaxpage').click( function(e) {
      var a = this;  // store ref to anchor element
      a.parents('div.paginator').html('loading...');
      $.ajax( {
           type: 'GET',
           dataType: 'html',
           url: a.attr('href'),
           success: function(data) {
               a.parents('div.paginator').html(data);
           }
       });
       return false;
   });
};


Mike


On 7/24/07, can xiang <[EMAIL PROTECTED]> wrote:

Hi, Dear group user

I'm tring to build a ajax paginator, here is my code:

$(document).ready( function(){

var opts = {
    target : '#id-search-result',
    url : '/query/',
    success : paginator_hook,
    };
var form_id = '#id-search-form';

function paginator_hook(){
$('div.paginator a.ajaxpage').click( function(e) {
        $(this).parents('div.paginator').html('loading...');
        $.ajax( {
                    type : 'GET',
                    dataType : 'html',
                    url : $(this).attr('href'),
                    success: function(data){ $
(this).parents('div.paginator').html(data); },
                });
        return false;
      });
};

$(form_id).ajaxForm(opts);
});

The context is I have a ajax form made with jquery ajaxForm plugin and
I want to show the result in a paginator. And the HTML is something
like this:

<form id="id-search-form">
</form>

<div class="paginator" id="id-search-result">
<div id="result-from-ajax-response">
</div>
<div id="pagnav">
<a href="/pagination/path" class="ajaxpage">Paginator Link</a>
</div>
</div>

I can get AJAX response when I clicked on the paginator links, but the
wrapper div didn't get updated with the responseText(that's to say,
"success" callback failed). Is there anybody encountered the same
problem and kind to offer me help?

I appreciated if you can give some hint.

Best regards!
Can


Reply via email to