Hi,

Initially when an AJAX search is run, a list of links (pagination) are created similarly to the code below. Each link contains a single parameter 'f'. 'f' contains the paged number ie
Code:
?f=2
. When one of the links built by AJAX is selected I can not get the value of 'f'. I need to do this as I'm not returning all search results at once; only the first 10. I need to pass the current paged number to the php file that is AJAX called.

HTML Code:
$("body").on("click", "#paged_results a", function(event){
            
            var terms = $('#terms').val();
            var f = $.QueryString["f"];
            console.log('clicked '+ f); //This always shows in the console as 'clicked null'
           $.ajax({
            type: "POST",
                    url: 'elasticsearch.php',
                   data: {
                        term: terms
                        , from_record: f
                  },
                  success: function( data ) {


                console.log( data );
                    
                        var term = '<h2>' + data['term'] + '</h2>';
                        var color = '<span style="display: block; width: 200px; height: 20px; background-color: ' + data['color'] + ';" ></span>';
                        var raw_results =  data['results'];


                        var table = '<table>';
                    var table_header = '<tr>';
                    table_header = table_header + '<th>ID</th>';
                    table_header = table_header + '<th>Abstract</th>';
                    table_header = table_header + '<th>Post</th>';
                    table_header = table_header + '<th>Copyright</th>';
                    table_header = table_header + '<th>Creation Date</th>';
                    table_header = table_header + '<th>Make</th>';
                    table_header = table_header + '<th>Tags</th>';
                    table_header = table_header + '</tr>';
                    var undefined = '<td>--</td>';
                    var table_body = '';
                    var tags = '';
                    for ( var key in raw_results ) {
                        table_body = table_body + '<tr>';
                        table_body = table_body + '<td>' + raw_results[key].id + '</td>';
                        table_body = table_body + '<td>' + raw_results[key].abstract + '</td>';
                        table_body = table_body + '<td>' + raw_results[key].body + '</td>';
                        table_body = table_body + '<td>' + raw_results[key].copyright + '</td>';
                        
                        var date = new Date( raw_results[key].created * 1000 );
                        table_body = table_body + '<td>' + date + '</td>';


                        if( typeof raw_results[key].make == 'undefined' ) {
                            table_body = table_body + undefined;
                        } else {
                            table_body = table_body + '<td>' + raw_results[key].make + '</td>';
                        }


                        if( raw_results[key].tags ) {
                            
                            table_body = table_body + '<td>';
                            
                            var count = raw_results[key].tags.length;
                            
                            var i = 1;
                            for( var inner_key in raw_results[key].tags ) {
                                
                                if( i < count ) {
                                    tags = tags + raw_results[key].tags[inner_key] + ', ';
                                } else {
                                    tags = tags + raw_results[key].tags[inner_key];
                                }
                                i++;
                                
                                
                                table_body = table_body + tags;
                                tags = '';
                                
                            }
                            table_body = table_body + '</td>';    
                        }
                        
                        table_body = table_body + '</tr>';
                    }
                    table = table + table_header + table_body + '</table';


                    
                    
                $('#hit_count').html( '<p>about ' + data['count'] +' results </p>');
                    $('#decor').html( color );
                    $('#title').html( term );


                    // Round down
                    var paging_groups = Math.floor( data['count'] / 10 );
                    var base_url = $(location).attr('href');
                    var f = $.QueryString['f'];
                    if ( typeof f != 'undefined' ) {
                        if ( paging_groups > 10 ) {
                            var paging_links = '<ul id="paged_results" >';
                            for( i = f; i <=10; i++ ) {
                                paging_links = paging_links + '<li>';
                                paging_links = paging_links + '<a href="' + base_url + '?f=' + i + '">' + i + ', </a>';
                                paging_links = paging_links + '</li>';
                            }
                        }
                        paging_links = paging_links + '</ul>';
                        $('#paging').html( paging_links );
                    }
  
                    $('#results').html ( table );
    
                }
            });
        });
    });


    /*
    * Search for a specific query string
    * Look for params on the url from ? and also the hash
    * Then check each parameter and split in on the equal sign
    * Using indexOf is the position of the character which represents the key/value
    * Having it split check whether the parameter has a value or not, if it has then store the value of d, if not 
    * just continue
    */
    $.QueryString = (function(a) {
        if (a == "") return {};
        var b = {};
        for (var i = 0; i < a.length; ++i)
        {
            var p=a[i].split('=');
            if (p.length != 2) continue;
            b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
        }
        return b;
    })(window.location.search.substr(1).split('&'))
You can see that currently the $.QueryString object is used to get the url paramters. This object works fine when one creates url parameters from the get go.

The links that get build from the first time a user searches are like:
HTML Code:
<a href="http://myproj/test-elastic-ajax-call.php#?f=4">4, </a>

I'm thinking this may have something to do with the links being constructed 'on live'; like the links that could not be clicked until i bound the events using 'on'.

Your thoughts on why the parameter can not be found even though clicking on the link shows the url + parameter and the click event fires.

Thanks,
Steve