Question: I have a script in javascript that load more information on page scroll down.
The problem is that when I scroll down the script is executed twice and I have the same result twice or even more.

I want to execute the script once each time I scroll down and not execute it twice or even more each time.

This is the script:

```js
$(window).scroll(function(){

        var lastID = $('.load-more').attr('lastid');
        if ($(window).scrollTop() == $(document).height() - $(window).height() && lastID != 0){
            $.ajax({
                type:'POST',
                url:'getdata.php',
                data:'id='+lastID,
                beforeSend:function(html){
                    $('.load-more').show();
                },
                success:function(html){
                    $('.load-more').remove();
                    $('#list').append(html);
                }
            });
        }
    });

```

Answer: 
Thanks everyone for trying to help.

Given that I'm flattening the output of **pool2** to perform just one matmul, the solution is to explicitly compute the length of the second dimension of the reshape. This is computed on lines 1 and 2, where the **[1:]** offset on the first line comes from the variable batch size.

I could not use reshape with all dimensions being unspecified.

```
pool2_shapes = pool2.get_shape().as_list()[1:]
pool2_features_length = reduce(lambda x, y: x*y, pool2_shapes)
reshape = tf.reshape(pool2, [tf.shape(images)[0], pool2_features_length])

```
`tf.shape` returns a tensor, so *dim* in `[dim, 384]` is a Tensor; here is an int needed.

Try `dim = reshape.get_shape().as_list()[1]` # output is of int type