Hello.
I'm new with the Prototypejs. But want to give some example of
possible mistakes, to save time for others
I had the problem with the eval of the response of the completed
request:
1. I've created the sample code
var path = ((inpObject.form.action == '') ? document.location :
inpObject.form.action);
new Ajax.Request(path, {
parameters: { param : "test" },
onSuccess: function(response) {
alert("abrakadabra - test :)")
}
});
2. I've put the server side code:
header("Content-Type: application/javascript");
echo "alert('hello! I`m from the server');";
3. Run the script with the Firebug opened.
Request was sent to the server, and as response I got the text:
alert('hello! I`m from the server');
Also the message box "abrakadabra - test :)" was appeared.
But then I get the script excution error and the response text is not
evaluated. The same with IE.
The error
"this.url.match is not a function
[Break on this error] var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
"
The line 1517 in the 1.6.1 version of Prototype.
In this part:
isSameOrigin: function() {
var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
return !m || (m[0] == '#{protocol}//#{domain}
#{port}'.interpolate({
protocol: location.protocol,
domain: document.domain,
port: location.port ? ':' + location.port : ''
}));
},
Solution:
The main mistake was the path variable that has the object
document.location
instead of document.location.href - the string.
Hope this will save time for someone.
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.