• 4 years later, WordPress still doesn’t provide ajax content-length header ^^’ So I patched my self the function :

    j’ai remplacé dans le fichier « wp-includes/class-wp-admin-ajax-response.php » cela :

    public function send() {
    header( ‘Content-Type: text/xml; charset=’ . get_option( ‘blog_charset’ ) );
    
    echo « <?xml version=’1.0′ encoding=' » . get_option( ‘blog_charset’ ) . « ‘ standalone=’yes’?><wp_ajax> »;
    foreach ( (array) $this->responses as $response )
    echo $response;
    echo ‘</wp_ajax>’;
    if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX )
    wp_die();
    else
    die();
    }

    par

    public function send() {
    $xml = « <?xml version=’1.0′ encoding=' » . get_option(‘blog_charset’) . « ‘ standalone=’yes’?><wp_ajax> »;
    foreach ( (array) $this->responses as $response )
    $xml .= $response;
    $xml .= ‘</wp_ajax>’;
    $length = strlen($xml);
    header(‘Content-Type: text/xml; charset=’ . get_option(‘blog_charset’));
    header(‘Content-Length: ‘.$length);
    header(‘Date: ‘.date(DATE_RFC1123));
    echo $xml;
    if ( defined( ‘DOING_AJAX’ ) && DOING_AJAX )
    wp_die();
    else
    die();
    }

    More informations : http://live.otakugame.fr/enfin-la-nouvelle-interface-pour-commenter-arrive-sur-otakugame-fr/

    The error occurs only on Google Chrome 😉 !

Viewing 1 replies (of 1 total)
  • Thread Starter SuzuKube

    (@suzukube)

    I think this patch should be include in wordpress 🙂 There is the same problem when updating plugins for example… It occurs on Varnish Servers.

Viewing 1 replies (of 1 total)

The topic ‘WordPress and encoding errors in AJAX REQUEST with Chrome.’ is closed to new replies.