wp_localize_script( 'ajax_script', 'WPURLS',array('siteurl' => get_option('siteurl')));
Then in script:
WPURLS.siteurl will contain the url.
When wp_localize_script is called, it takes your data and passes it through to the script in object form.
Also keep in mind, localize_script needs to be called AFTER a script is registered and enqueued.