Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2745] Ti.Include returns 500 because it uses "POST" not "GET"

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionWon't Fix
Resolution Date2011-10-13T12:44:01.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
LabelsHTML5, Mobile
ReporterChristopher Spence
AssigneePaul Dowsett
Created2011-10-12T11:26:59.000+0000
Updated2016-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);
}

Comments

  1. Christopher Spence 2011-10-13

    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.
  2. Paul Dowsett 2011-10-13

    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.
  3. Paul Dowsett 2011-12-27

    Ticket resolved and not updated since last curator action.

JSON Source