I have a form where the user inputs data and a table that shows all the rows in the database. Now when the user clicks an "edit"-link next to one of the rows I want to post the ID to the PHP file and load the data in the row into the form. 

This is how I post the ID (and it works)

```
jQuery('a.edit').on('mousedown', function(){
    var id = jQuery(this).attr('data-title');
    jQuery.ajax({
        url: document.location,
        data: {id: id}
    });
})

```

This is how I tried to receive the posted ID (doesn't work)

```
if( isset( $_GET['id'] ) ){
    $id = $_GET['id'];
    load_data($id);
}

```

I guess I need to refresh the page? How can I do that? Can I also just refresh the form?

**EDIT:** I still think it's a reload/refresh issue. The value is being posted, but my PHP doesn't recognize because it is not reloaded. I've seen people doing this with jQuery instead of reloading the whole page, but I fail to recreate this. Maybe it is also worth mentioning that theses files are part of a Wordpress Plugin..

So this is the whole code (my plugin is called "spielerportraits")

spielerportraits-admin.php

```
<?php 
function print_data(){
    global $wpdb;
    $datatable = $wpdb->get_results( 
        'SELECT * FROM ' . $wpdb->prefix . 'spielerportraits' ); 
?>

<table id="spieler-output">
    <tr>
        <td>Name</td>
        <td>Geb.datum</td>
    </tr>

<?php foreach( $datatable as $data ) { ?>
    <tr>
        <td><?php echo $data->name; ?></td>
        <td><?php echo $data->gebdatum; ?></td>
        <td><a href="" class="edit" data-title="<?php echo $data->id;?>">bearbeiten</a></td> // The edit-link for jQuery
    </tr>

<?php }
?>
    </table>
<?php
} 

if(isset($_GET['id'])){
    global $wpdb;
    $loaddata = $wpdb->get_row( 
        'SELECT * FROM '.$wpdb->prefix.'spielerportraits WHERE id = '.$_GET['id'] ); 
}
?>

<form enctype="multipart/form-data" name="spieler-form" action="" method="post">
    <table id="spieler-input">
        <tr>
            <td>Name: </td>
            <td><input type="text" name="name" value="<?php if( isset($loaddata) ){echo $loaddata->name;}?>" size="40"></td>
        </tr>
        <tr>
            <td>Geburtsdatum: </td>
            <td><input type="text" name="gebdatum" value="<?php if( isset($loaddata) ){echo $loaddata->gebdatum;}?>" size="40"></td>
        </tr>
        <tr>
            <td class="submit">
                <input type="submit" name="submit" value="Hinzufügen" />
            </td>
        </tr>
    </table>
</form>

<?php
    print_data();
?>

```

The JS

```
jQuery('a.edit').on('mousedown', function(){
    var id = jQuery(this).attr('data-title');
    jQuery.ajax({
        url: document.location,
        data: {id: id},
        success: function(data){
            alert(data['id']); // This does show, but gives me 'undefined'
        }
    });
});

```

And this is how the plugin is initialised in Wordpress (spielerportraits.php):

```
<?php

add_action( 'admin_enqueue_scripts', 'spielerportraits_style' );
add_action('admin_menu', 'spielerportraits_custom_menu_page');

function spielerportraits_custom_menu_page() {
   $page = add_menu_page( 'Spielerportraits', 'Spielerportraits', 'manage_options', 'spielerportraits/spielerportraits-admin.php', '', '' ), 33 );
}

function spielerportraits_style() {
    wp_enqueue_script( 'spielerportraits-admin-script', plugins_url('/script.js', __FILE__) );

}

global $jal_db_version;
$jal_db_version = "1.0";

function jal_install() {
   global $wpdb;
   global $jal_db_version;

   $table_name = $wpdb->prefix . 'spielerportraits';

   $sql = "CREATE TABLE $table_name (
        id int NOT NULL AUTO_INCREMENT,
        name tinytext NOT NULL,
        gebdatum date',
        PRIMARY KEY id (id)
    );";

    if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name ) {
        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
        dbDelta( $sql );
        add_option( "jal_db_version", $jal_db_version );
    }
}

register_activation_hook( __FILE__, 'jal_install' );

?>

```