Add an option to set a timeout for XHR requests (#95)
Closes #24.
This commit was merged in pull request #95.
This commit is contained in:
@@ -15,12 +15,17 @@ module.exports = function(location, options, callback) {
|
||||
}
|
||||
}
|
||||
|
||||
request.ontimeout = function() {
|
||||
callback(null, request)
|
||||
}
|
||||
|
||||
// Add a timestamp as part of the query string if cache busting is enabled
|
||||
if (this.options.cacheBust) {
|
||||
location += (!/[?&]/.test(location) ? "?" : "&") + new Date().getTime()
|
||||
}
|
||||
|
||||
request.open(requestMethod.toUpperCase(), location, true)
|
||||
request.timeout = options.timeout
|
||||
request.setRequestHeader("X-Requested-With", "XMLHttpRequest")
|
||||
request.setRequestHeader("X-PJAX", "true")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user