[AC-2745] Ti.Include returns 500 because it uses "POST" not "GET"
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2011-10-13T12:44:01.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | HTML5, Mobile |
Reporter | Christopher Spence |
Assignee | Paul Dowsett |
Created | 2011-10-12T11:26:59.000+0000 |
Updated | 2016-03-08T07:47:38.000+0000 |
Description
Perhaps this is an issue with the server side, but from my understanding you're supposed to be using "GET" and not "POST" when requesting a script file. Ti.include (Ti.js ln 43) calls _loadSyncScript, which does an XHR call using "POST", which causes the call to fail and the script not returned.
The working code:
function _loadSyncScript(_location) {
if ('undefined' != typeof _loadedScripts[_location]) {
return _execScript(_loadedScripts[_location]);
}
var _xhr = new XMLHttpRequest();
_xhr.onreadystatechange = function() {
if (_xhr.readyState == 4) {
if (_xhr.status == 200) {
_loadedScripts[_location] = _xhr.responseText;
_execScript(_xhr.responseText);
}
}
};
_xhr.open("GET",_location,false);
_xhr.setRequestHeader("Access-Control-Allow-Origin","*");
_xhr.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
_xhr.send(null);
}
Also on a side note, I would imagine the content-type should be set to "application/javascript" when retrieving a script, but I left it as "text/xml" since the code is now working even with "text/xml" in place.
I am sorry, Christopher, but we do not support software until its official release. That said, this part of the product is being rewritten, so it should be resolved by the next version. Thanks for your input.
Ticket resolved and not updated since last curator action.