Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

    add_action('wp_head','get_gz_info',30);
    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'); ?>';
            $.post(ajaxurl,modal,function(data){
                $('body').append(data);
            });
        });
        </script>
    <?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.

share|improve this question
    
Are there are any errors in the console? –  Andrew Bartel Apr 25 '13 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 Apr 25 '13 at 2:52
    
if I print to the console or echo everything runs fine. Anything inside the $.post isn't run. –  dcp3450 Apr 25 '13 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/… –  Andrew Bartel Apr 25 '13 at 2:57
    
According to the inspect this is being set as the ajaxurl, "http://...my site url.../wp-admin/admin-ajax.php" –  dcp3450 Apr 25 '13 at 2:58
show 10 more comments

1 Answer

up vote 1 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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