Open jwestbrook opened 10 years ago
Yaffle March 15th, 2009 @ 08:52 AM
IE throws exception "wrong argument" please somebody make patch
Jon March 22nd, 2012 @ 08:18 PM
A similar test case, but in plain html.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Ajax.Request('');</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
new Ajax.Request('', {
onException : function(request, exception) { alert('exception'); },
onSuccess : function() { alert('ok'); },
});
</script>
</head>
</html>
Jon March 22nd, 2012 @ 08:19 PM
A test case that illustrates underlying behavior of IE.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>XMLHttpRequest.open("GET", "", true);</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
try {
var oReq = new XMLHttpRequest;
oReq.open("GET", "", true);
alert("ok");
} catch (e) {
alert("exception");
}
</script>
</head>
</html>
Jon March 22nd, 2012 @ 08:21 PM
A patch for avoiding this IE bug in prototype.
From 2c34ffaf997ee7ac5538ccd4c3d4dd6291236aff Mon Sep 17 00:00:00 2001
From: Jon Wilkes <jonny+lh@mail.hfa3.org>
Date: Thu, 22 Mar 2012 12:03:07 -0700
Subject: [PATCH] Avoid IE exception when new Ajax.Request('');
---
src/prototype/ajax/request.js | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/src/prototype/ajax/request.js b/src/prototype/ajax/request.js
index f50ece6..0bf64df 100644
--- a/src/prototype/ajax/request.js
+++ b/src/prototype/ajax/request.js
@@ -177,6 +177,10 @@ Ajax.Request = Class.create(Ajax.Base, {
},
request: function(url) {
+ // Avoid IE 8 lameness
+ if (Prototype.Browser.IE && url.empty()) {
+ url = window.location.href;
+ }
this.url = url;
this.method = this.options.method;
var params = Object.isString(this.options.parameters) ?
--
1.7.3.4
Victor March 23rd, 2012 @ 05:03 PM
request: function(url) {
// default URL
this.url = url || window.location.href;
this.method = this.options.method;
Marking as an enhancement because it's papering over some under-specified behavior in browsers. Should get to this with the rest of the 1.8 Ajax enhancements.
previous lighthouse ticket #597 by Spezi
When calling
(empty string for the first argument) the request is not sent, even no JavaScript error message appears. This also happens if the first argument is null. I wanted to use this to send an XHR to exactly the same page used for generating the output. If the first argument is ' ' (space) or '.' (dot), the request is sent, but that's just a workaround.
Tested with prototype 1.6.0.3 on Windows. In Firefox 3.0.7 and IE 7 the behavior is as described. For Opera 9.64 and Safari 3.2.2 the request is sent even with '' (empty string) but not with null for the first argument.
I attach a simple test environment for this using PHP. Just add prototype-1.6.0.3.js and call index.php.