vendor/assets/javascripts/jquery.iframe-transport.js in remotipart-1.0 vs vendor/assets/javascripts/jquery.iframe-transport.js in remotipart-1.0.1

- old
+ new

@@ -111,11 +111,11 @@ // Remove "iframe" from the data types list so that further processing is // based on the content type returned by the server, without attempting an // (unsupported) conversion from "iframe" to the actual type. options.dataTypes.shift(); - + if (files.length) { // Determine the form the file fields belong to, and make sure they all // actually belong to the same form. files.each(function() { if (form !== null && this.form !== form) { @@ -175,36 +175,36 @@ // The `send` function is called by jQuery when the request should be // sent. send: function(headers, completeCallback) { iframe = $("<iframe src='javascript:false;' name='iframe-" + $.now() + "' style='display:none'></iframe>"); - + // The first load event gets fired after the iframe has been injected // into the DOM, and is used to prepare the actual submission. iframe.bind("load", function() { // The second load event gets fired when the response to the form // submission is received. The implementation detects whether the // actual payload is embedded in a `<textarea>` element, and // prepares the required conversions to be made in that case. iframe.unbind("load").bind("load", function() { - + var doc = this.contentWindow ? this.contentWindow.document : (this.contentDocument ? this.contentDocument : this.document), root = doc.documentElement ? doc.documentElement : doc.body, textarea = root.getElementsByTagName("textarea")[0], type = textarea ? textarea.getAttribute("data-type") : null; - - var status = 200, + + var status = textarea ? parseInt(textarea.getAttribute("response-code")) : 200, statusText = "OK", responses = { text: type ? textarea.value : root ? root.innerHTML : null }, headers = "Content-Type: " + (type || "text/html") completeCallback(status, statusText, responses, headers); setTimeout(cleanUp, 50); }); - + // Now that the load handler has been set up, reconfigure and // submit the form. form.attr("action", options.url) .attr("target", iframe.attr("name")) .attr("enctype", "multipart/form-data")