Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
1.60/5 (2 votes)
See more:
Hi,

The code is not working in Mozilla but seems to be working fine in Chrome. Thank you for helping.

JavaScript
function addItem(str) {
	var request;
	if (window.XMLHttpRequest){//firefox etc.
		request = new XMLHttpRequest();
	}
	else if (window.ActiveXObject){//ie
		request = new ActiveXObject("Microsoft.XMLHTTP");
	}
	request.open('GET', "checkinout-actions/add-more-items-code.php?q="+str);
 
	request.onreadystatechange = function () {
		if (request.readyState == 1) { return }
		else if (request.readyState == 4) {
			if (request.status < 400) {
				// do your stuff here
				document.getElementById("txtHint").innerHTML=request.responseText;
			}
			else if (error != null)
				error(request);
		}
	};
	request.send();
	window.location.reload();
}
Posted
Comments
Mohibur Rashid 13-May-15 0:20am    
Your code works fine. both in firefox ans chrome.
Where do you see your bug? What does the bug says? It certainly does not says that "XMLHttpRequest not working"
Sergey Alexandrovich Kryukov 13-May-15 1:10am    
Of course it works. No doubt.
—SA

Remove the line window.location.reload() and try again.

Run the code in the Mozilla debugger and see what is happening.
 
Share this answer
 
Comments
Mohibur Rashid 13-May-15 3:59am    
firefox or not window.location.reload will make all data to get lost in the space.
+5
A big warning for you: window.ActiveXObject is a huge abuse, very unsafe. If some demanding users will see that you use such dirty things, they can blacklist your site. Never do such things, just scratch it out. All non-nonsense browsers will work without it, and those which cannot does not deserve any attention; they are way too obsolete.

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900