Click here to Skip to main content
15,891,424 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: print preview Pin
merapyar24-Jan-07 0:32
merapyar24-Jan-07 0:32 
GeneralRe: print preview Pin
Bradml24-Jan-07 0:54
Bradml24-Jan-07 0:54 
GeneralRe: print preview Pin
Bradml24-Jan-07 1:21
Bradml24-Jan-07 1:21 
GeneralRe: print preview Pin
merapyar24-Jan-07 1:44
merapyar24-Jan-07 1:44 
GeneralRe: print preview Pin
Bradml24-Jan-07 1:48
Bradml24-Jan-07 1:48 
GeneralRe: print preview Pin
merapyar24-Jan-07 1:49
merapyar24-Jan-07 1:49 
GeneralRe: print preview Pin
Bradml24-Jan-07 1:53
Bradml24-Jan-07 1:53 
QuestionProblem with XMLHTTPRequest [modified] Pin
xfitr223-Jan-07 17:47
xfitr223-Jan-07 17:47 
I am having a problem where I am sending XMLHTTPRequest in a for loop [function: updateStatus()] and only the last row in the loop's style attributes get updated on the page [function: StatusChange()], but each XMLHTTPRequest is making the correct change on the server. Is there a way to wait for each callback, change the style attributes and then go on to the next call? Any suggestions would be helpful.

Summary:
UpdateStatus()
|_calls StatusChange()
|_loadXMLDoc()

processReqChange()
|_call StatusChange() -> with a response to update nodes

<script language="javascript"><br />
	var req;<br />
	<br />
	function loadXMLDoc(url) {<br />
		req = false;<br />
			// branch for native XMLHttpRequest object<br />
			if(window.XMLHttpRequest && !(window.ActiveXObject)) {<br />
    		try {<br />
				req = new XMLHttpRequest();<br />
					} catch(e) {<br />
				req = false;<br />
					}<br />
			// branch for IE/Windows ActiveX version<br />
			} else if(window.ActiveXObject) {<br />
       		try {<br />
        		req = new ActiveXObject('Msxml2.XMLHTTP');<br />
      		} catch(e) {<br />
        		try {<br />
          			req = new ActiveXObject('Microsoft.XMLHTTP');<br />
        		} catch(e) {<br />
          			req = false;<br />
        		}<br />
					}<br />
				}<br />
		if(req) {<br />
			req.open("GET", url, true);<br />
			req.onreadystatechange = processReqChange;<br />
			req.send("");<br />
		}<br />
	}<br />
	<br />
	function processReqChange() {<br />
		//only if req shows "complete"<br />
		if (req.readyState == 4) {<br />
			//only if "OK"<br />
			if (req.status == 200) {<br />
				//...processing statements go here<br />
				response = req.responseXML.documentElement;<br />
				method = response.getElementsByTagName('method')[0].firstChild.data;<br />
				result = response.getElementsByTagName('result')[0].firstChild.data;<br />
				status = response.getElementsByTagName('status')[0].firstChild.data;<br />
				invoice = response.getElementsByTagName('invoice')[0].firstChild.data;<br />
				eval(method + '(invoice, status, result)');<br />
			} else {<br />
				alert('There was a problem retrieving the XML data:\n ' + req.statusText);<br />
			}<br />
		}<br />
	}<br />
<br />
	function updateStatus(status) {<br />
		var tblrows = document.getElementById('wtgridScreen_dgScreen').rows;<br />
		if (tblrows != null) {<br />
			for (i = 1; i < tblrows.length - 1; i++) {<br />
				if(tblrows[i].cells[0].children[0].children[0].checked) {<br />
					var sid = tblrows[i].cells[1].attributes['record_keys'].value;<br />
					StatusChange(sid, status, '');<br />
					//Input Mode<br />
				}<br />
			}<br />
		}<br />
	}<br />
	<br />
	function StatusChange(id, status, response) {<br />
		if (response != '') {<br />
			//Response Mode<br />
			if (response == 'Success') {<br />
				tblrows = document.getElementById('wtgridScreen_dgScreen').rows;<br />
				if (tblrows != null) {<br />
					for (i = 1; i < tblrows.length - 1; i++) {<br />
						sid = tblrows[i].cells[1].attributes['record_keys'].value;<br />
						if (sid == ('id=' + id)) {<br />
							oRow = tblrows[i];<br />
							oRow.style.backgroundColor = '#FFFFFF';<br />
							oRow.cells[0].children[0].children[0].checked = false;<br />
						}<br />
					}<br />
				}<br />
			}<br />
		} else {<br />
			//Input Mode<br />
			url = 'http://localhost/ptweb/custompages/_xmlInvoiceStatus.aspx';<br />
			url += '?method=StatusChange&' + id + '&status=' + status + '&reason=';<br />
			loadXMLDoc(url);<br />
		}<br />
	}<br />
</script>

AnswerRe: Problem with XMLHTTPRequest Pin
andyharman24-Jan-07 2:50
professionalandyharman24-Jan-07 2:50 
GeneralRe: Problem with XMLHTTPRequest Pin
xfitr224-Jan-07 4:08
xfitr224-Jan-07 4:08 
GeneralRe: Problem with XMLHTTPRequest Pin
xfitr224-Jan-07 4:19
xfitr224-Jan-07 4:19 
AnswerRe: Problem with XMLHTTPRequest Pin
xfitr224-Jan-07 4:44
xfitr224-Jan-07 4:44 
QuestionCan Javascript be used to alter XSL ? Pin
Red_Wizard_Shot_The_Food23-Jan-07 5:49
Red_Wizard_Shot_The_Food23-Jan-07 5:49 
AnswerRe: Can Javascript be used to alter XSL ? Pin
Shajeel23-Jan-07 22:16
Shajeel23-Jan-07 22:16 
GeneralRe: Can Javascript be used to alter XSL ? Pin
David Domingues26-Jan-07 2:48
David Domingues26-Jan-07 2:48 
QuestionScheduled Task Pin
VK-Cadec23-Jan-07 3:22
VK-Cadec23-Jan-07 3:22 
AnswerRe: Scheduled Task Pin
Bradml23-Jan-07 4:11
Bradml23-Jan-07 4:11 
QuestionVS 2005 Web Configuration Question Pin
Leo Smith23-Jan-07 3:18
Leo Smith23-Jan-07 3:18 
AnswerRe: VS 2005 Web Configuration Question Pin
Alexandru Lungu1-Feb-07 7:57
professionalAlexandru Lungu1-Feb-07 7:57 
Questionsuggest small java project name Pin
m4u.maulik23-Jan-07 1:31
m4u.maulik23-Jan-07 1:31 
AnswerRe: suggest small java project name Pin
Bradml23-Jan-07 1:48
Bradml23-Jan-07 1:48 
Questionasp.net Pin
rahulsinghalmastermind23-Jan-07 0:17
rahulsinghalmastermind23-Jan-07 0:17 
AnswerRe: asp.net Pin
Shajeel23-Jan-07 22:25
Shajeel23-Jan-07 22:25 
QuestionDiv tag scrollbars Pin
raghuvarma22-Jan-07 22:54
raghuvarma22-Jan-07 22:54 
AnswerRe: Div tag scrollbars Pin
Bradml23-Jan-07 0:22
Bradml23-Jan-07 0:22 

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.