WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Ajax in subsite (5 posts)

  1. Herbert
    Member
    Posted 3 years ago #

    I have the Ajax content working in a sub-site set up as sub-directory. When I change to domain mapping the Ajax stops working.

    The following code is in my sub-site child theme header.php:

    jQuery.ajax({
         url:"<?php bloginfo('url')?>/wp-admin/admin-ajax.php",
         type:'POST',
         data:'action=my_special_action&main_postid=' + mainPostID,
         dataType: 'html',
         beforeSend: function() {
             jQuery('#test').html('<img src="<?php echo get_stylesheet_directory_uri(); ?>/images/ajax-loading.gif" alt="pagina is aan het laden..." />');
                 if(!mainPostID) {
                     $('#test').html('<p>Oops! There is no data...</p>');
                     return false;
                 }
         },
         success:function(result) {
         // alert(result);
         jQuery("#test").html(result);
         }
    
     });

    It probably has something to do with the call to admin-ajax.php.
    So I tried using the full domain of the main website, that did not work.
    I also used the domain of the sub-website. That did not work.

    Hope someone can point me into the right direction.

  2. When you change to domain mapping, go Edit the site so all the references to the subdomain are gone.

  3. Herbert
    Member
    Posted 3 years ago #

    When you change to domain mapping, go Edit the site so all the references to the subdomain are gone.

    Thanks for the response.
    Can you explain what you mean with 'edit the site'?
    I am not using subdomain but virtual domain and the sub-sites are set up as sub-directory sites in the main blog.
    There is no problem with the sub-site it works perfectly under the virtual domain. There is only the problem that the ajax content doesn't load anymore...

  4. Herbert
    Member
    Posted 3 years ago #

    UPDATE:
    I checked in FireBug for the post to /wp-admin/admin-ajax.php it shows a "302 Moved Temporarily" that is why it is not working I guess. It also refers to jQuery.js line 130.

    Ideas anybody...?

  5. Herbert
    Member
    Posted 3 years ago #

    SOLVED:
    In the domain mapping configuration do NOT select: "Redirect administration pages to site's original domain (remote login disabled if redirect disabled)".

    Now my ajax content is working on the virtual domain!

Topic Closed

This topic has been closed to new replies.

About this Topic