:: Forum >>

Alex.... please look: xmlhttp JS

Alex, I hold a commercial license, and am experimenting with v2.

I'm not fluent in JS... but this project is really helping me learn.

I've spend HOURS trying to get this to work. Perhaps I just can't see the nose on my face and it's really simple. Please have a look and tell me where I might be going wrong.

As far as I can see, all your examples use files or arrays for data... and I'm just too frustrated to continue trying to figure this out on my own.

I am 100% certain that the EMtestDB.asp file returns valid XML data.

I am also 100% certain that the Javascript invoking the xmlHttp object is working fine and receiving the XML.

If I do check the contents of xmlDoc.xml on line 31, I get all the stuff I should get.

The problem is loading it into the table object on line 33. I've tried 100 different ways to do this... and none have worked. Please help.

Thanks in advance...

Tim

Here's my code...

1 var request;
2 var url = 'EMtestDB2.asp';
3 if (window.XMLHttpRequest) {
4 request = new XMLHttpRequest();
5 request.onreadystatechange = processReqChange;
6 request.open("POST", url, true);
7 request.send(null);
8 } else if (window.ActiveXObject) {
9 window.XMLHttpRequest = function() {
10 var a = [ 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP', 'Msxml2.XMLHTTP.3.0'];
11 i = a.length; while(i--) {
12 try {
13 return new ActiveXObject( a[i] );
14 } catch (e) { }
15 }
16 return null;
17 };
18 if( window.XMLHttpRequest ) {
19 request = new XMLHttpRequest();
20 }
21 if (request) {
22 request.onreadystatechange = processReqChange;
23 request.open("POST", url, true);
24 request.send();
25 }
26 }
27
28 function processReqChange() {
29 if (request.readyState == 4) {
30 if (request.status == 200) {
31 xmlDoc=request.responseXML
32 var table=new AW.XML.Table;
33 table.setXML(xmlDoc);
34 var obj = new AW.UI.Grid;
35 obj.setColumnCount(5);
36 obj.setRowCount(5);
37 obj.setCellModel(table);
38 document.write(obj);
39 } else {
40 alert("Problem with XML data:\n" + request.statusText);
41 }
42 }
43}

Tim Milo
Sunday, January 22, 2006
Tim Milo
Monday, January 23, 2006
Tim,

one thing which seem to be wrong in your code is using document.write() inside processReqChange() handler. At this point the page has already finished loading, so document.write() will clear all page content. Instead you should use something like parentDIV.innerHTML = obj.

Alex (ActiveWidgets)
Monday, January 23, 2006
Also I am not sure why you are creating your own XMLHTTPRequest object - AW.XML.Table already does all that, so it might be more simple just using AW.XML.Table for making request.
Alex (ActiveWidgets)
Monday, January 23, 2006
OOOOhhhhhh! NOW I get it.

I did not realize you had built in smlhttp object into the table object.

Now that you've said that... I had it working in just 5 minutes!!!!

Thanks
Tim Milo
Monday, January 23, 2006
can you post ur working code now?
Ben
Tuesday, March 21, 2006
heh, yeah I see that all the time on this forum, they complain there is no ajax support, blah blah... for some reason people don't seem to notice the really nice built in cross browser http interface, you should promote it more. I mean its not that hard to write your own code for it, but it is handy having it integrated with the API.
LinuxFreakus
Tuesday, March 21, 2006

This topic is archived.


Back to support forum

Forum search