Skip to main content

Bug Tracker

Side navigation

#15118 closed bug (fixed)

Opened May 29, 2014 04:31PM UTC

Closed June 02, 2014 08:40PM UTC

Error using "jquery/ajax" with AMD

Reported by: tj.vantoll Owned by:
Priority: low Milestone: 1.12/2.2
Component: ajax Version: 1.11.1
Keywords: Cc:
Blocked by: Blocking:

I'm trying to create snippets of how to use pieces of jQuery outside of the whole library. For a basic AJAX call I'm attempting to use the following:

define([ "jquery/ajax" ], function( $ ) {
	$.ajax( "http://whatever" );

But I get an error on this line because

is undefined. If I use this block the call works:

define([ "jquery/event", "jquery/ajax/xhr" ], function( $ ) {
	$.get( "http://whatever" );

So my question is: should ajax.js depend on event.js?

Attachments (0)
Change History (5)

Changed May 29, 2014 05:29PM UTC by dmethvin comment:1

milestone: None1.12/2.2
priority: undecidedlow
status: newopen

Ugh. Well technically yes, you need event. However I think all the event work it does is guarded by the global option which defaults to true. So if you pass in global: false it won't try to trigger ajax events.

It seems like one solution here would be to check for jQuery.event and skip firing global events if it's not defined. There can't possibly be anyone listening for the event if that's the case, right?

Changed May 29, 2014 05:50PM UTC by tj.vantoll comment:2

I verified that setting

avoids this problem.

This is tricky, but I think a quick check for

is a good idea. 99.9% of people are not micromanaging Core, and for those that are, it'd be nice to see
streamlined (and small in terms of bytes).

I'll put a PR together.

Changed May 29, 2014 05:58PM UTC by dmethvin comment:3

I think it's a really quick extra conditional to where we set fireGlobals

Changed May 30, 2014 01:52PM UTC by tj.vantoll comment:4

Changed June 02, 2014 08:40PM UTC by TJ VanToll comment:5

resolution: → fixed
status: openclosed

Ajax: Support usage without jQuery.event

Fixes #15118

Closes gh-1588

Changeset: d41e81980ea89e56c04eb14d8c27f4692b367604