WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#27737 closed feature request (duplicate)

maybe a get_ajax_url() function?

Reported by: igmoweb Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.8.2
Component: General Keywords:
Focuses: javascript, administration Cc:
PR Number:

Description

Hi there.

I'll explain a case where the way to get the ajax URL in http://codex.wordpress.org/AJAX_in_Plugins is not working.

If FORCE_SSL_ADMIN is set to true but not the front, then using admin_url( admin-ajax.php' ) in front will return a https URL that will lead us to the following error when we try to trigger an AJAX action:

... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ...

Because if Javascript calls to an https URL it should be called from another https in the same site.

So, I want to ask for an ajax_url() function that checks SSL constants and return a different URL depending on them.

Basically, the function would return something like this:

admin_url( 'admin-ajax.php', (is_ssl() ? 'https' : 'http') );

Yeah, I could add it in every plugin but why not a function with that code included? Am I crazy asking for it?

Change History (1)

#1 @DrewAPicture
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #19707.

See comment:4:ticket:19707

Note: See TracTickets for help on using tickets.