Debugger and application creash when using XmlHttpWebRequest

Debugger and application creash when using XmlHttpWebRequest

BY 28 Sep 2016 Web Application Development

I am creatint a Tizen Web application for controlling a device. The device exposes it’s functionality by hosting an HTTP server and receives commands in query strings. The result of each operation is sent back in a binary response. I’ve got no trouble in calling the functionality but I see odd behaviour when I try to read the response. This is how I’m reading it. 

 

    	var request = new XMLHttpRequest();
		request.responseType = 'arraybuffer';
		request.open('GET', applyPassword(commandURL), true);
		request.onload = function(e) {
			try {
			var response = request.response;
                        //Everything freezes on next line
			if(request.status == 200) {
				var responseArray = new Uint8Array(response); 
				for(var i=0;i<responseArray.length;++i) {
					console.log(responseArray[i]);
				}
			}
			catch(exc)
			{
				console.log(exc);
			}
			//}
		};
		request.onerror = function(e) {
			console.log(e);
			console.log(e.responseText);
		};
		request.send();
	};

While the call succeeds when I attempt to check the request status the debugger becomes non-functional. and the application non-responsive. Given the simplicity of the code this is an unexpected response. Has anyone experienced anything similar and know of any work arounds?

 

Written by