Skip to content

Commit 1a934eb

Browse files
MaddieM4fieg
authored andcommitted
Use the loadEvent object to provide arbitrary $.get settings
The jQuery AJAX API is pretty powerful. Rather than trying to wrap all of its abilities, for questionable gain, we can just use the load event object as the settings parameter. This lets downstream users override arbitrary settings, like `headers` or `cache` or `timeout`. The downside is if people are storing funky, non-url things in the load event, this will break their use case. But it's kind of a weird thing to do in the current IAS interface, so we probably don't have to be too paranoid about backwards compatibility. For people who only use event.url, or don't use the event object at all, they won't even know anything changed.
1 parent 8308e10 commit 1a934eb

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/jquery-ias.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,13 @@
182182
delay = delay || this.defaultDelay;
183183

184184
var loadEvent = {
185-
url: url
185+
url: url,
186+
dataType: 'html'
186187
};
187188

188189
self.fire('load', [loadEvent]);
189190

190-
this.jsXhr = $.get(loadEvent.url, null, $.proxy(function(data) {
191+
function xhrDoneCallback(data) {
191192
$itemContainer = $(this.itemsContainerSelector, data).eq(0);
192193
if (0 === $itemContainer.length) {
193194
$itemContainer = $(data).filter(this.itemsContainerSelector).eq(0);
@@ -211,7 +212,9 @@
211212
callback.call(self, data, items);
212213
}
213214
}
214-
}, self), 'html');
215+
}
216+
this.jsXhr = $.get(loadEvent)
217+
.done($.proxy(xhrDoneCallback, self));
215218

216219
return this.jsXhr;
217220
};

0 commit comments

Comments
 (0)