WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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
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

Your Answer


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.