Two possible solutions here-
Solution one is to not hardcode the modal markup into the template and instead use the wp_footer action to insert it, along with your data:
function wpa_wp_footer(){
$someval = 'foo'; // get_option results
echo '<div id="modalpopup"><div id="inside">' . $someval . '</div></div>';
}
add_action( 'wp_footer', 'wpa_wp_footer' );
Personally, I would do it this way, as simple as it gets, keeps it theme-agnostic.
Solution two is more in line with your original idea, and gets the data to javascript so you can insert it yourself. But instead of making a separate request for the data via ajax, localize the script to have the data printed to the page when it's rendered.
Here's your standard enqueue for adding javascript to a theme, along with the localize call to add extra data.
function wpa_scripts() {
wp_enqueue_script(
'wpa_script', // script handle
get_template_directory_uri() . '/js/script.js',
array('jquery'),
null,
true
);
// do your get_option here to set whatever data you're passing
$script_data = array(
'some_var' => 'someval'
);
wp_localize_script(
'wpa_script', // the script handle enqueued above
'wpa_data',
$script_data
);
}
add_action( 'wp_enqueue_scripts', 'wpa_scripts' );
Then in your javascript, access the data like:
jQuery('#inside').html( wpa_data.some_var );
jQuery(document).readyinstead of onsubmitor onclick...