Closed mrf345 closed 5 years ago
Please show the code you're using that's "attempting XMLHttpRequest". You've only shown the exception.
What resource are you trying to get/head/post? Is it on the same origin as your main document?
@swhiteman Thanks for the prompt replay 👍
I don't get the whole picture myself, but the general idea is: I have a huge model that contains a time-out function that handles updating items, so it will make the XMLHttpRequest
then updates the items:
toggleItems: function () {
var self = this;
if (gotTimedOut) clearTimeout(gotTimedOut)
gotTimedOut = setTimeout(function () {
self.retrieveItems(self.filterItems(self))
// retrieveItems will do the XMLHttpRequest with req-json and sort out the items
})
}
retrieveItems: function (filteredItems) {
// do some sorting of existing items
var req = new ReqJSON({
'async': false,
'url': window.location + 'someEndPoint',
'onSuccess': callback
}).send(JSON.encode(theDataToSubmit))
// do some more filtering
}
The exception showed before leads to this chunk of mootools.js
:
this.fireEvent('request');
xhr.send(data);
if (!this.options.async) this.onStateChange();
if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this);
return this;
Interesting warning message i got from mootools.js
before the exceptions was raised:
Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help http://xhr.spec.whatwg.org/
While debugging i tried to resend the data and got this exception:
[Exception... "Component not initialized" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: debugger eval code :: <TOP_LEVEL> :: line 1" data: no]
But you still haven't included the relevant information about the main document's origin and the XHR destination's origin.
The common sync XHR warning does not itself stop a request from going out but that doesn't mean a CORS response can be processed.
My bad, i'm trying to post
on the same origin. the request stoped and the first exception got raised.
Do you have a live repro of this problem (CodePen, jsFiddle, et al.)?
No i don't. I've encountered it during E2E testing on a local dev environment.
I guess you'll have to work toward a public repro case.
Curious if you get the same result with the well-known port for HTTP (TCP 80). What about with GET? And are you absolutely sure the XHR is being sent to the same origin (protocol + hostname + port)?
I will try setting up one later.
I'm sure of the same origin as it is attempting to post to window.location.href + ...
.
Good idea i'll try get
instead, and try running the test on chrome too.
Thanks a lot @swhiteman
Turns out it was an authentication issue with the post request. Thanks, and sorry for wasting your time @swhiteman .
Hello there, I'm new to mootools so bear with me please :) I'm having a strange issue while E2E testing. I'm using
mootools 1.4.0
withFirefox 45.0.1
While attemptingXMLHttpRequest
this exception gets raised:I did
try
catch
to pass the test error free for now. Thanks in advance 👍