WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#19224 closed defect (bug) (invalid)

ajaxurl not defined for Android / iPhone browsers

Reported by: exz Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: General Keywords:
Focuses: Cc:

Description

When trying to do an ajax call using the ajaxurl variable, it works perfectly in a desktop browser but not from my smartphone, HTC Desire HD using their standard browser. The problem has also been reproduced using an iPhone 4.

I've verified this as an issue using the Twenty Eleven theme and without any plugins, using WordPress 3.2.1 multisite installation.

Steps to reproduce:

  1. Go to jsconsole.com
  2. Type :listen
  3. Copy the javascript and insert it into the footer of the Twenty Eleven theme
  4. Open site with your smartphone
  5. Try sending 'ajaxurl', 'console.log(ajaxurl)' or 'alert(ajaxurl)' from jsconsole

The result from this command sent to the phone browser is:

ajaxurl is not defined

I've ruled out issues with jsconsole.com by trying to send something else to the phone browser and looking at the response. For instance 'window', 'document.title' and 'window.localStorage' all returns the correct result from the phone browser.

Going to the same site with my Chrome browser, typing ajaxurl into the console gives:

"http://[hostname]/wp-admin/admin-ajax.php"

Change History (5)

comment:1 dd322 years ago

FWIW, it definitely works in Opera Mobile in the Admin at least.

Does <script>alert(ajaxurl);</script> fail when placed in the footer as well?

comment:2 exz2 years ago

Yes.

This code:

<script>alert('hello'); alert(ajaxurl);</script>

Will alert "Hello" but nothing more. Same result for my HTC Desire HD and iPhone 4.

comment:3 exz2 years ago

Update:

It now seems more like the issue is that the ajaxurl variable is only getting defined for users that are signed in, which is still an issue but it doesn't seem like it's related to the platform/browser.

comment:4 exz2 years ago

  • Resolution set to invalid
  • Status changed from new to closed

"Note: Unlike on the admin side, the ajaxurl javascript global does not get automatically defined for you - unless you have BuddyPress installed."

I'm, sorry for reporting this.

comment:5 ocean902 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.