I have this JS/jQuery code

```
window.onload = function(){

    var request = $.ajax({
    url: "../wp-content/plugins/woocommerce/admin/test.php",
    type: "GET",            
    dataType: "html"
    //data: {$lastid},
    });

    request.done(function(msg) {
        $(".recent-orders").append(msg);
    });

    request.fail(function(jqXHR, textStatus) {
        alert( "Request failed: " + textStatus );
    });
EDIT: This is the method where I get the $lastid.

<?php
function woocommerce_dashboard_recent_orders() {

    $args = array(
        'numberposts'     => 8,
        'orderby'         => 'post_date',
        'order'           => 'ASC',
        'post_type'       => 'shop_order',
        'post_status'     => 'publish'
    );
    $orders = get_posts( $args );
    if ($orders) :
    echo '<ul class="recent-orders">';
        foreach ($orders as $order) :

            $this_order = new WC_Order( $order->ID );

            echo '
            <li>
                <span id = "order-$order->ID" class="order-status '.sanitize_title($this_order->status).'">'.ucwords(__($this_order->status, 'woocommerce')).'</span> <a href="'.admin_url('post.php?post='.$order->ID).'&action=edit">' . get_the_time( __( 'l jS \of F Y h:i:s A', 'woocommerce' ), $order->ID ) . '</a><br />
                <small>'.sizeof($this_order->get_items()).' '._n('item', 'items', sizeof($this_order->get_items()), 'woocommerce').' <span class="order-cost">'.__('Total:', 'woocommerce' ) . ' ' . woocommerce_price($this_order->order_total).'</span></small>
            </li>';

        endforeach;
        $lastid = $order->ID;
        echo '</ul>';
    else:
        echo '<p>' . __( 'There are no product orders yet.', 'woocommerce' ) . '</p>';
    endif;
}
?>

```

That calls a php file called test.php.

test.php

```
    <?php
//woocommerce_dashboard_recent_orders_realtime();

/**
 * Init the dashboard widgets.
 *
 * @access public
 * @return void
 */

function filter_where( $where = '' ) {
    $oid = 2100;
    $where = " AND ID > $oid";

    return $where;

}

add_filter( 'posts_where', 'filter_where' );

    $args = array(
        'numberposts'     => 8,
        'orderby'         => 'post_date',
        'order'           => 'DESC',
        'post_type'       => 'shop_order',
        'post_status'     => 'publish',
        'suppress_filters' =>  FALSE
    );

    $orders = get_posts( $args );

    if ($orders) :
        foreach ($orders as $order) :
            //echo " $order->ID";
            $this_order = new WC_Order( $order->ID );
            echo '
            <li>
                <span id = "order-$order->ID" class="order-status '.sanitize_title($this_order->status).'">'.ucwords(__($this_order->status, 'woocommerce')).'</span> <a href="'.admin_url('post.php?post='.$order->ID).'&action=edit">' . get_the_time( __( 'l jS \of F Y h:i:s A', 'woocommerce' ), $order->ID ) . '</a><br />
                <small>'.sizeof($this_order->get_items()).' '._n('item', 'items', sizeof($this_order->get_items()), 'woocommerce').' <span class="order-cost">'.__('Total:', 'woocommerce' ) . ' ' . woocommerce_price($this_order->order_total).'</span></small>
            </li>';

            //echo (gettype($time3));
        endforeach;

    endif;
//}
?>

```

What I want to do is to pass the $lastid from the javascript to the test.php file and receive it as something like $lastid also.

I know I should post, but I'm having trouble using it. Can anyone lead me to the right method? 

My CODE now

```
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript" >
window.onload = function(){
    //setInterval(function(){
        //var lastid = '<?php echo $lastid; ?>';
        //alert(lastid);
        var request = $.ajax({
        url: "../wp-content/plugins/woocommerce/admin/test.php",
        type: "POST",      
        dataType: "html",
        data: { lastid : '<?php echo $lastid; ?>'},
        });

        request.done(function(msg) {
            $(".recent-orders").append(msg);
        });

        request.fail(function(jqXHR, textStatus) {
            alert( "Request failed: " + textStatus );
        });
        //addElement();

    //},1000);
setInterval(function(){

},1000);

}

</script>

<?php
function woocommerce_dashboard_recent_orders() {

    $args = array(
        'numberposts'     => 8,
        'orderby'         => 'post_date',
        'order'           => 'ASC',
        'post_type'       => 'shop_order',
        'post_status'     => 'publish'
    );
    $orders = get_posts( $args );
    if ($orders) :
    echo '<ul class="recent-orders">';
        foreach ($orders as $order) :

            $this_order = new WC_Order( $order->ID );

            echo '
            <li>
                <span id = "order-$order->ID" class="order-status '.sanitize_title($this_order->status).'">'.ucwords(__($this_order->status, 'woocommerce')).'</span> <a href="'.admin_url('post.php?post='.$order->ID).'&action=edit">' . get_the_time( __( 'l jS \of F Y h:i:s A', 'woocommerce' ), $order->ID ) . '</a><br />
                <small>'.sizeof($this_order->get_items()).' '._n('item', 'items', sizeof($this_order->get_items()), 'woocommerce').' <span class="order-cost">'.__('Total:', 'woocommerce' ) . ' ' . woocommerce_price($this_order->order_total).'</span></small>
            </li>';

        endforeach;
        $lastid = $order->ID;
        echo '</ul>';
    else:
        echo '<p>' . __( 'There are no product orders yet.', 'woocommerce' ) . '</p>';
    endif;
}
?>

<?php
function filter_where( $where = '' ) {
    $oid = 2110;
    $where = " AND ID > $oid";

    return $where;

}

$lastid = $_GET['lastid'];

add_filter( 'posts_where', 'filter_where' );

    $args = array(
        'numberposts'     => 8,
        'orderby'         => 'post_date',
        'order'           => 'DESC',
        'post_type'       => 'shop_order',
        'post_status'     => 'publish',
        'suppress_filters' =>  FALSE
    );

    $orders = get_posts( $args );
    echo "LAST ID: $lastid";
    if ($orders) :
        foreach ($orders as $order) :
            $this_order = new WC_Order( $order->ID );

            echo '
            <li>
                <span id = "order-$order->ID" class="order-status '.sanitize_title($this_order->status).'">'.ucwords(__($this_order->status, 'woocommerce')).'</span> <a href="'.admin_url('post.php?post='.$order->ID).'&action=edit">' . get_the_time( __( 'l jS \of F Y h:i:s A', 'woocommerce' ), $order->ID ) . '</a><br />
                <small>'.sizeof($this_order->get_items()).' '._n('item', 'items', sizeof($this_order->get_items()), 'woocommerce').' <span class="order-cost">'.__('Total:', 'woocommerce' ) . ' ' . woocommerce_price($this_order->order_total).'</span></small>
            </li>';

        endforeach;

    endif;
    remove_filter( 'posts_where', 'filter_where' );
//}
?>

```