Get WordPress page Id inside customizer

I think you work about the ajax call. Inside the theme, in the right frame works all default WP functions inside the loop. But if you get the post inside the customizer you can use the ajax call and get the id from the URL.

Source Example

JavaScript

add_action( 'wp_ajax_fb_custom', 'fb_customizer_ajax' );
function fb_customizer_ajax() {

    if ( ! wp_verify_nonce( $_POST[ 'ajaxnonce' ], 'fb_customize_ajax_nonce' ) ) {
        die( -1 );
    }

    $current_url = $_POST[ 'current_url' ];
    $current_id  = url_to_postid( $current_url );
    echo $current_id . '<br>' . $current_url;
    die();
}

PHP

The same should be possible in php. Use the help of the function url_to_postid(), this return value is the ID of the post for a url. The url is in the global _GET, like $_GET['url'].