Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#11487 closed defect (bug) (wontfix)

Fix AJAX bug created by web hosts who inject ads into html pages

Reported by: palotasb Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: General Keywords: close
Focuses: Cc:


Most web hosting companies insert ads into HTML pages downloaded from them. This breaks some admin page features, because files downloaded via AJAX have a text/html header and the host automatically injects the ads. This sometimes creates a reload cycle or makes the page completely unaccessible.

I have fixed the issue partly by editing /wp-admin/admin-ajax.php at line 19 and /wp-admin/index-extra.php at line 18, by overwriting the Content-Type header to be text/plain. This does not fix the issue on the admin dashboard, where some widgets need to be disabled.

I suggest that any content not rendered directly by the browser (used for AJAX data transfer only, processed by JavaScript, where only content matters) should be transferred using a text/plain header. This should be a straightforward change and I don't think it could cause any bugs (actually, it works for me), but you may want to investigate.

In case you want to reproduce, you have to set up a web server in a way that it injects some content into the body of every served file with the text/html MIME type.

Change History (2)

#1 @Denis-de-Bernardy
12 years ago

  • Keywords close added; free web hosting ads admin removed

Most web hosting companies insert ads into HTML pages downloaded from them.

That sounds so 1995... I haven't run into a hosting company that does this in *ages*.

Suggesting we close this as wontfix.

@palotasb: If you need free WP hosting, consider using wordpress.com. If you need to host WP yourself, several cheap hosts are highlighted on wordpress.org.

#2 @filosofo
12 years ago

  • Milestone Unassigned deleted
  • Resolution set to wontfix
  • Status changed from new to closed

That's pretty ridiculous. Like Denis said, if you need free or cheap hosting, there are better options.

Since this is such an obscure problem, it's really just plugin material:

function my_text_header() {

   if ( is_defined('DOING_AJAX') && DOING_AJAX  ) {
     @header('Content-Type: text/plain; charset=' . get_option('blog_charset'));

add_action('admin_init', 'my_text_header');

Note: See TracTickets for help on using tickets.