I have some script that works on my dev server but not on my staging server:

    function get_gz_info(){
        <script type="text/javascript" >
        jQuery(document).ready(function($) {
                var modal = {action:'modal_action'};
                var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';

the php is roughly:

add_action('wp_ajax_modal_action', 'set_modal');
    add_action('wp_ajax_nopriv_modal_action', 'set_modal');
    function set_modal() {

Everything works fine on my dev side but the staging side the javascript is placed in the header (just like the dev) but it won't run the "ajax part". Could it be that the staging side requires a username/password to access it?

I've attempted it with and without the https and get the same results

----- EDIT -----

Note: I'm using ajax in the admin on the staging server it that works fine. It's only on the user side that I'm having an issue.

  • Are there are any errors in the console? Commented Apr 25, 2013 at 2:47
  • A few but nothing that relates the issue and that isn't seen on the dev server. Such as a font file warning and some issue chrome is having with a couple extensions.
    – dcp3450
    Commented Apr 25, 2013 at 2:52
  • if I print to the console or echo everything runs fine. Anything inside the $.post isn't run.
    – dcp3450
    Commented Apr 25, 2013 at 2:54
  • Have you verified that ajaxurl is being set correctly on the live server? It's better to do it with a wp_localize_script() call. Hate to link my own answer, but see step 2: wordpress.stackexchange.com/questions/96795/… Commented Apr 25, 2013 at 2:57
  • According to the inspect this is being set as the ajaxurl, "http://...my site url.../wp-admin/admin-ajax.php"
    – dcp3450
    Commented Apr 25, 2013 at 2:58

1 Answer 1


The person who setup the staging server placed and .htaccess in the admin side that prevented the site from accessing files in the wp-admin area.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.