: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
if (io.contentWindow.document.execCommand) {
io.contentWindow.document.execCommand('Stop');
$io.attr('src', s.iframeSrc); // abort op in progress
s.error.call(s.context, xhr, e, status);
$.event.trigger('ajaxError', [xhr, s, e]);
s.complete.call(s.context, xhr, e);
// trigger ajax global events so that activity/block indicators work like normal
if (g && $.active++ === 0) {
$.event.trigger('ajaxStart');
$.event.trigger('ajaxSend', [xhr, s]);
if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
// add submitting element to data if we know it
if (n && !sub.disabled) {
s.extraData = s.extraData || {};
s.extraData[n] = sub.value;
if (sub.type === 'image') {
s.extraData[n + '.x'] = form.clk_x;
s.extraData[n + '.y'] = form.clk_y;
var CLIENT_TIMEOUT_ABORT = 1;
/* it looks like contentWindow or contentDocument do not
* carry the protocol property in ie8, when running under ssl
* frame.document is the only valid response document, since
* the protocol is know but not on the other two objects. strange?
* "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy
// IE8 cascading access check
if (frame.contentWindow) {
doc = frame.contentWindow.document;
// IE8 access denied under ssl & missing protocol
log('cannot get iframe.contentWindow document: ' + err);
if (doc) { // successful getting content
try { // simply checking may throw in ie8 under ssl or mismatched protocol
doc = frame.contentDocument ? frame.contentDocument : frame.document;
log('cannot get iframe.contentDocument: ' + err);
// Rails CSRF hack (thanks to Yvan Barthelemy)
var csrf_token = $('meta[name=csrf-token]').attr('content');
var csrf_param = $('meta[name=csrf-param]').attr('content');
if (csrf_param && csrf_token) {
s.extraData = s.extraData || {};
s.extraData[csrf_param] = csrf_token;
// take a breath so that pending repaints get some cpu time before the upload starts
// make sure form attrs are set
var t = $form.attr2('target'),
a = $form.attr2('action'),
mp = 'multipart/form-data',
et = $form.attr('enctype') || $form.attr('encoding') || mp;
// update form attrs in IE friendly way
form.setAttribute('target', id);
if (!method || /post/i.test(method)) {
form.setAttribute('method', 'POST');
form.setAttribute('action', s.url);
// ie borks in some cases when setting encoding
if (!s.skipEncodingOverride && (!method || /post/i.test(method))) {
encoding : 'multipart/form-data',
enctype : 'multipart/form-data'
timeoutHandle = setTimeout(function() {
timedOut = true; cb(CLIENT_TIMEOUT_ABORT);
// look for server aborts
var state = getDoc(io).readyState;
if (state && state.toLowerCase() === 'uninitialized') {
setTimeout(checkState, 50);
log('Server abort: ', e, ' (', e.name, ')');
cb(SERVER_ABORT); // eslint-disable-line callback-return
clearTimeout(timeoutHandle);
timeoutHandle = undefined;
// add "extra" data to form if provided in options
for (var n in s.extraData) {
if (s.extraData.hasOwnProperty(n)) {
// if using the $.param format that allows for multiple values with the same name
if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
$('<input type="hidden" name="' + s.extraData[n].name + '">', ownerDocument).val(s.extraData[n].value)
$('<input type="hidden" name="' + n + '">', ownerDocument).val(s.extraData[n])
// add iframe to doc and submit the form
io.attachEvent('onload', cb);
io.addEventListener('load', cb, false);
setTimeout(checkState, 15);
// just in case form has element with name/id of 'submit'
var submitFn = document.createElement('form').submit;
// reset attrs and remove "extra" input elements
form.setAttribute('action', a);
form.setAttribute('enctype', et); // #380
form.setAttribute('target', t);
$form.removeAttr('target');
setTimeout(doSubmit, 10); // this lets dom updates render
var data, doc, domCheckCount = 50, callbackProcessed;
if (xhr.aborted || callbackProcessed) {
log('cannot access response document');
if (e === CLIENT_TIMEOUT_ABORT && xhr) {
deferred.reject(xhr, 'timeout');
if (e === SERVER_ABORT && xhr) {
xhr.abort('server abort');
deferred.reject(xhr, 'error', 'server abort');
if (!doc || doc.location.href === s.iframeSrc) {
// response not received yet
io.detachEvent('onload', cb);
io.removeEventListener('load', cb, false);
var status = 'success', errMsg;
var isXml = s.dataType === 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
if (!isXml && window.opera && (doc.body === null || !doc.body.innerHTML)) {
// in some browsers (Opera) the iframe DOM is not always traversable when
// the onload callback fires, so we loop a bit to accommodate
log('requeing onLoad callback, DOM not available');
// let this fall through because server response could be an empty document
// log('Could not access iframe DOM after mutiple tries.');
// throw 'DOMException: not available';
// log('response detected');
var docRoot = doc.body ? doc.body : doc.documentElement;
xhr.responseText = docRoot ? docRoot.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
xhr.getResponseHeader = function(header){
var headers = {'content-type': s.dataType};
return headers[header.toLowerCase()];
// support for XHR 'status' & 'statusText' emulation :
xhr.status = Number(docRoot.getAttribute('status')) || xhr.status;
xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
var dt = (s.dataType || '').toLowerCase();
var scr = /(json|script|text)/.test(dt);
// see if user embedded response in textarea
var ta = doc.getElementsByTagName('textarea')[0];
xhr.responseText = ta.value;
// support for XHR 'status' & 'statusText' emulation :
xhr.status = Number(ta.getAttribute('status')) || xhr.status;
xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
// account for browsers injecting pre around json response
var pre = doc.getElementsByTagName('pre')[0];
var b = doc.getElementsByTagName('body')[0];
xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;
xhr.responseText = b.textContent ? b.textContent : b.innerText;
} else if (dt === 'xml' && !xhr.responseXML && xhr.responseText) {
xhr.responseXML = toXml(xhr.responseText); // eslint-disable-line no-use-before-define
data = httpData(xhr, dt, s); // eslint-disable-line no-use-before-define
xhr.error = errMsg = (err || status);
log('error caught: ', err);
xhr.error = errMsg = (err || status);
if (xhr.status) { // we've set xhr.status
status = ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 304) ? 'success' : 'error';
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (status === 'success') {
s.success.call(s.context, data, 'success', xhr);
deferred.resolve(xhr.responseText, 'success', xhr);
$.event.trigger('ajaxSuccess', [xhr, s]);
if (typeof errMsg === 'undefined') {
s.error.call(s.context, xhr, status, errMsg);
deferred.reject(xhr, 'error', errMsg);
$.event.trigger('ajaxError', [xhr, s, errMsg]);
$.event.trigger('ajaxComplete', [xhr, s]);
$.event.trigger('ajaxStop');
s.complete.call(s.context, xhr, status);
callbackProcessed = true;
clearTimeout(timeoutHandle);
} else { // adding else to clean up existing iframe response.
$io.attr('src', s.iframeSrc);
var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
if (window.ActiveXObject) {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc = (new DOMParser()).parseFromString(s, 'text/xml');
return (doc && doc.documentElement && doc.documentElement.nodeName !== 'parsererror') ? doc : null;
var parseJSON = $.parseJSON || function(s) {
return window['eval']('(' + s + ')'); // eslint-disable-line dot-notation
var httpData = function(xhr, type, s) { // mostly lifted from jq1.4.4
var ct = xhr.getResponseHeader('content-type') || '',
xml = ((type === 'xml' || !type) && ct.indexOf('xml') >= 0),
data = xml ? xhr.responseXML : xhr.responseText;
if (xml && data.documentElement.nodeName === 'parsererror') {
data = s.dataFilter(data, type);
if (typeof data === 'string') {
if ((type === 'json' || !type) && ct.indexOf('json') >= 0) {
} else if ((type === 'script' || !type) && ct.indexOf('javascript') >= 0) {
* ajaxForm() provides a mechanism for fully automating form submission.
* The advantages of using this method instead of ajaxSubmit() are:
* 1: This method will include coordinates for <input type="image"> elements (if the element
* is used to submit the form).
* 2. This method will include the submit element's name/value data (for the element that was
* used to submit the form).
* 3. This method binds the submit() method to the form for you.
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
* passes the options argument along after properly binding events for submit elements and
$.fn.ajaxForm = function(options, data, dataType, onSuccess) {
if (typeof options === 'string' || (options === false && arguments.length > 0)) {
if (typeof onSuccess === 'function') {
options.success = onSuccess;
options.delegation = options.delegation && $.isFunction($.fn.on);
// in jQuery 1.3+ we can fix mistakes with the ready state
if (!options.delegation && this.length === 0) {
var o = {s: this.selector, c: this.context};
log('DOM not ready, queuing ajaxForm');
$(o.s, o.c).ajaxForm(options);