Click here to Skip to main content
15,899,754 members
Home / Discussions / JavaScript
   

JavaScript

 
SuggestionRe: combo box values not working for quote calculator Pin
Richard MacCutchan28-Nov-13 22:55
mveRichard MacCutchan28-Nov-13 22:55 
GeneralRe: combo box values not working for quote calculator Pin
Matt Harville28-Nov-13 23:03
Matt Harville28-Nov-13 23:03 
GeneralRe: combo box values not working for quote calculator Pin
Richard MacCutchan28-Nov-13 23:27
mveRichard MacCutchan28-Nov-13 23:27 
GeneralRe: combo box values not working for quote calculator Pin
Graham Breach29-Nov-13 3:06
Graham Breach29-Nov-13 3:06 
Questionhow to connect oracle database using jsp Pin
maheshkadtan28-Nov-13 8:14
maheshkadtan28-Nov-13 8:14 
SuggestionRe: how to connect oracle database using jsp Pin
Richard Deeming28-Nov-13 8:46
mveRichard Deeming28-Nov-13 8:46 
AnswerRe: how to connect oracle database using jsp Pin
Richard MacCutchan28-Nov-13 22:53
mveRichard MacCutchan28-Nov-13 22:53 
QuestionXMLHttpRequest (a)synchronous file upload Pin
csrss26-Nov-13 19:41
csrss26-Nov-13 19:41 
Hi guys. I do not know JS / AJAX / Web tech, I just need plain and simple mechanism for multiple files upload.
Currently I have this (taken from the net actually):

JavaScript
function uploader(place, targetPHP) 
{
	// Function drop file
	this.drop = function(event) 
	{
		event.preventDefault();
		var dt = event.dataTransfer;
		var files = dt.files;

		var progressBar = document.querySelector('progress');
		for (var i = 0; i < files.length; i++) 
		{
			var file = files[i];
		
			xhr = new XMLHttpRequest();
			xhr.open('POST', targetPHP, false);
			xhr.setRequestHeader('UP-FILENAME', file.name);
			xhr.setRequestHeader('UP-SIZE', file.size);
			xhr.setRequestHeader('UP-TYPE', file.type);
			xhr.onreadystatechange = function()
			{
				if(this.readyState == 4 && this.status == 200)
				{
					progressBar.value = Math.round((i * 100) / files.length);
				}
			}
			xhr.send(file); 
		}
		progressBar.value = 100;
		setTimeout("location.reload(true);", 2000);
	}
	
	// The inclusion of the event listeners (DragOver and drop)
	this.uploadPlace =  document.getElementById(place);
	this.uploadPlace.addEventListener("dragover", function(event)
	{
		event.stopPropagation(); 
		event.preventDefault();
	}, true);
	this.uploadPlace.addEventListener("drop", this.drop, false); 
}


This thing uploading files synchronously one by one but it makes a browser, such as IE for example, freezes. I need to modify
this script the way it will be doing same but asynchronously. So it will upload one file, then in onreadystatechange event
it will trigger next file upload. This is because my server is a 2 threaded application, which processes XMLHttpRequest one by one.
Basically, I got no idea how to modify this script that way because I do not know js / ajax at all.
I was trying to collect files into an array, which was a class member, and then process them but uploader just stopped
after first file upload.
Thanks in advance.
011011010110000101100011011010000110100101101110
0110010101110011

AnswerRe: XMLHttpRequest (a)synchronous file upload Pin
csrss26-Nov-13 21:17
csrss26-Nov-13 21:17 
Questiononkeypress event is not working google chrome Pin
Mithra Madhu25-Nov-13 20:36
Mithra Madhu25-Nov-13 20:36 
QuestionRe: onkeypress event is not working google chrome Pin
ZurdoDev6-Dec-13 10:28
professionalZurdoDev6-Dec-13 10:28 
Questionrestrict file type and size of form upload javascript only Pin
vbslacker24-Nov-13 8:37
vbslacker24-Nov-13 8:37 
AnswerRe: restrict file type and size of form upload javascript only Pin
Snehasish_Nandy24-Nov-13 20:06
professionalSnehasish_Nandy24-Nov-13 20:06 
AnswerRe: restrict file type and size of form upload javascript only Pin
abdul0425-Nov-13 23:53
abdul0425-Nov-13 23:53 
Question[Javascript] Find unused funtions and variables in Javascript using VS2010 Ultimate Pin
Member 1041144619-Nov-13 2:47
Member 1041144619-Nov-13 2:47 
AnswerRe: [Javascript] Find unused funtions and variables in Javascript using VS2010 Ultimate Pin
thatraja19-Nov-13 3:16
professionalthatraja19-Nov-13 3:16 
QuestionHaving a Problem with Return Value in Javascript Function Pin
Doug Pruiett12-Nov-13 16:25
Doug Pruiett12-Nov-13 16:25 
AnswerRe: Having a Problem with Return Value in Javascript Function Pin
Graham Breach12-Nov-13 22:44
Graham Breach12-Nov-13 22:44 
GeneralRe: Having a Problem with Return Value in Javascript Function Pin
Doug Pruiett13-Nov-13 3:30
Doug Pruiett13-Nov-13 3:30 
GeneralRe: Having a Problem with Return Value in Javascript Function Pin
Graham Breach13-Nov-13 5:27
Graham Breach13-Nov-13 5:27 
AnswerRe: Having a Problem with Return Value in Javascript Function Pin
Doug Pruiett13-Nov-13 4:19
Doug Pruiett13-Nov-13 4:19 
GeneralRe: Having a Problem with Return Value in Javascript Function Pin
Richard Deeming13-Nov-13 4:51
mveRichard Deeming13-Nov-13 4:51 
GeneralRe: Having a Problem with Return Value in Javascript Function Pin
Richard MacCutchan13-Nov-13 6:10
mveRichard MacCutchan13-Nov-13 6:10 
SuggestionRe: Having a Problem with Return Value in Javascript Function Pin
chxm199016-Nov-13 3:30
chxm199016-Nov-13 3:30 
QuestionShowing Questions Below Answers After The Submit Button Is Pressed? Pin
KeonD12311-Nov-13 10:25
KeonD12311-Nov-13 10:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.