Alec Posted July 18, 2011 Share Posted July 18, 2011 Hi all,I have the ollowing HTML file and I am trying to move the table and make it a static table inside <div id= dvtable>it is not pulling the information from the xml file if i move it.anybody can help?<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script> <script src="jquery.ba-dotimeout.js"></script> <script type="text/javascript"> $(document).ready(function(){ //gets the xml configuration file and creates an multidimension array called schedule and hands it off for display jQuery.get("schedule.xml", {}, function(xml) { var schedule = [] //iterates through the xml file and creates the schedule multidimension array $(xml).find('item').each(function(i){ var id = $(this).attr('id'); schedule[id] = { title: $(this).find('title').text(), position: $(this).find('position').text(), duration: $(this).find('duration').text(), url: $(this).find('url').text() } }); //end of each //passes the schedule multidimension array for display displayResults(schedule); }); //end of get }); //end of document.ready function displayResults(schedule){ var counter = 0; var z = 0; $.each(schedule, function(intIndex, objValue){ z = z + parseInt(objValue.duration); }); //this will give us a very long initial delay. How often should be iterate through? $.doTimeout(z, function(){ //be careful as this will override the exception $.each(schedule,function(intIndex, objValue){ setTimeout(function() { $('#iframe1').attr('src', objValue.url); }, this.duration * intIndex); }); //end of each //if ( counter < 50 ) { return true; } // Poll. not sure about this counter return true; //this will make it loop }); } </script> <script type="text/javascript"> $(document).ready(function(){ $.ajaxSetup ({ cache: false }); $.doTimeout(30000, function(){ $.ajax({ type: "GET", //url: "http://neptune.atlantixglobal.com:1048/cgi-bin/db2www/qsys.lib/sdsrc.lib/macros.file/tvsalesexc.mbr/report", //url: "result2.xml", url: "http://reports.atlantixglobal.com/tvs/files/result2.xml", cache: false, dataType:"xml", success: function(xml){ $(xml).find('item').each(function(i){ $('#table1').append('<tr ><td width="80%" align="center"><span style="font-size:80px"><FONT COLOR=RED FACE="sans-serif" ><B>Congratulations ' +$(this).find('name').text() +' !!!</B></FONT></span></td></tr>'); $('#table1').append('<tr ><td><FONT COLOR=white>......</FONT></td></tr>'); $('#table1').append('<tr ><td align="center"><span style="font-size:75px"><FONT FACE="Tahoma" ><B><i> You just closed a </i></B></FONT></span></td></tr>'); $('#table1').append('<tr ><td><FONT COLOR=white>......</FONT></td></tr>'); $('#table1').append('<tr ><td align="center"><span style="font-size:90px"><FONT COLOR= BLUE FACE="Tahoma" ><B><i> $ ' + $(this).find('amount').text() +' deal</i></B></FONT></span></td></tr>'); $('#table1').append('<tr ><td><FONT COLOR=white>......</FONT></td></tr>'); $('#table1').append('<tr ><td align="center"><span style="font-size:80px"><FONT FACE="Tahoma" ><B><i> with ' +$(this).find('customer').text() +'</i></B></FONT></span></td></tr>'); $('#iframe1').hide(); }); } }); $.doTimeout(10000, function(){ $("#table1 tr").remove(); $('#iframe1').show(); }); return true; }); }); </script> <style type="text/css"> .myTableStyle { position:absolute; top:10%; left:5%; } </style> </head><body> <table id = "table1" class="myTableStyle" ></table> <div id="1" style="z-index:10"> <iframe id="iframe1" src="" width="1920px" height="1080px" frameborder="0" scrolling="auto" style="border:0px solid #000000"> </iframe> </div> <div id="2" style="z-index:1"> <iframe id="iframe2" src="" width="100%" height="1000" frameborder="0" scrolling="auto" style="border:10px solid fff000"> </iframe> </div> </body> </html> Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 I dont care about having a table .I just need to get the information from ther xml file inside a div. So i can get rid of the table as well.Thanks, Link to comment Share on other sites More sharing options...
Ingolme Posted July 18, 2011 Share Posted July 18, 2011 it is not pulling the information from the xml file if i move it.What are you moving? The table or the XML file? Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 I am trying to get rid of the table so I can simplify the code.in order to do I was trying to move the information from inside the table into a div inside the html body.I'v been working on this for awhile (Hope I can get some help Link to comment Share on other sites More sharing options...
Ingolme Posted July 18, 2011 Share Posted July 18, 2011 You're trying to hardcode the XML data into the HTML file? Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 You're trying to hardcode the XML data into the HTML file?Yep Link to comment Share on other sites More sharing options...
Ingolme Posted July 18, 2011 Share Posted July 18, 2011 Since Javascript can't write the HTML file on the disk you're going to have to manually write the data. Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 How can I do that? Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 so what I am thinking to do is to move the data from the table and add it in a div in the html body .and then I call the div and remove it instead of having the table in the JS scriptI've been trying to do but not working!! Link to comment Share on other sites More sharing options...
jeffman Posted July 18, 2011 Share Posted July 18, 2011 This thread has gotten very confusing. Please explain if this describes the situation:An XML file exists on your server or someone else's server.A user loads an HTML file from your server into their browser.The HTML document uses AJAX to get the XML document.Then the HTML document writes the XML data into itself.Yes? No? Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 This thread has gotten very confusing. Please explain if this describes the situation:An XML file exists on your server or someone else's server.A user loads an HTML file from your server into their browser.The HTML document uses AJAX to get the XML document.Then the HTML document writes the XML data into itself.Yes? No?Yes indeed.. Link to comment Share on other sites More sharing options...
jeffman Posted July 18, 2011 Share Posted July 18, 2011 Okay. You need to test things.First you need to see if your AJAX request actually returned anything.Then you need to see if what it returned has been successfully turned into an XML object.With jQuery, maybe those two steps can be combined.Then you need to see if your XML functions are correctly access your XML data. Don't confuse the process by gooping it up with a lot of table stuff. You can do that later if you need to. Just see if you can write your XML strings into a div, may separating them with <br> elements, but nothing more complicated.What is going on with all the delays you're building into this thing? Why do you think that is necessary? Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 Okay. You need to test things.First you need to see if your AJAX request actually returned anything.Then you need to see if what it returned has been successfully turned into an XML object.With jQuery, maybe those two steps can be combined.Then you need to see if your XML functions are correctly access your XML data. Don't confuse the process by gooping it up with a lot of table stuff. You can do that later if you need to. Just see if you can write your XML strings into a div, may separating them with <br> elements, but nothing more complicated.What is going on with all the delays you're building into this thing? Why do you think that is necessary?the query as it is fine..everything in is working perfect and I am getting what I need from the XML file using Jquery.what I need to do is to move the output into div tags and then call the div instead of having the whole table.I tried several ways but it is not working.. Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 I tired to delete the table and added <div id ="divtable" class = "divRelative" > <script type="text/javascript"> $.doTimeout(30000, function(){ $.ajax({ type: "GET", //url: "http://neptune.atlantixglobal.com:1048/cgi-bin/db2www/qsys.lib/sdsrc.lib/macros.file/tvsalesexc.mbr/report", url: "result2.xml", cache: false, dataType:"xml", success: function(xml){ $(xml).find('item').each(function(i){ document.write ("<font color=red>"+$(this).find('name').text()+"<br></font>"); document.write ("<br>"); document.write (parseInt($(this).find('amount').text())); document.write ("<br>"); document.write ($(this).find('customer').text()); $('#iframe1').hide(); }); } }); }); </script> </div> inside the html body..I got the data working but lost the overwritting to show the other slides Link to comment Share on other sites More sharing options...
justsomeguy Posted July 18, 2011 Share Posted July 18, 2011 Don't use document.write. Build the complete HTML string first, then use innerHTML to update the div. Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 Don't use document.write. Build the complete HTML string first, then use innerHTML to update the div.I am sorry but i am not that expert...could you tell me how to do that or is there any examples i can take a look at?Thanks, Link to comment Share on other sites More sharing options...
justsomeguy Posted July 18, 2011 Share Posted July 18, 2011 The innerHTML property of elements lets you read or change the contents.http://www.w3schools.com/jsref/prop_html_innerhtml.asp Link to comment Share on other sites More sharing options...
Alec Posted July 18, 2011 Author Share Posted July 18, 2011 Thxs, I tried it ..it is working ..the only problem is that when the process goes back to repeat cycle it stock on one of the slides and I am getting :document.getElementById('name').innerHTML= $(this).find('name').text(); is nullany ideas ?! Link to comment Share on other sites More sharing options...
Alec Posted July 19, 2011 Author Share Posted July 19, 2011 The innerHTML property of elements lets you read or change the contents.http://www.w3schools.com/jsref/prop_html_innerhtml.asp Thank you for your help..it is working as i needed.. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.