JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2059
Number of posts: 5157

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Re: Help: Get data from url and write to table Posted by mac_doggie on 1 Mar 2010 at 2:04 PM
I don't think ajax will work cross domain, so you'll need to call a script on your own website to get the data, or you might be able to use an iframe, but I think then you can't manipulate it's contents if it's on another domain as well...

To answer the question of reading data from the url and placing it in a table you could do something like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <title></title>
  <script type="text/javascript">
   function createTable() {
      var params = document.location.search.substr(1).split('&');
      var table  = document.createElement('table');
      var tbody  = document.createElement('tbody');
      table.appendChild(tbody);
      for(var i=0;i<params.length;i++) {
         var pair = params[i].split('=');
         var tr1 = document.createElement('tr');
         var td1 = document.createElement('td');
         var td2 = document.createElement('td');
         td1.innerHTML = pair[0];
         td2.innerHTML = pair[1];
         tr1.appendChild(td1);
         tr1.appendChild(td2);
         tbody.appendChild(tr1);
      }
      document.getElementById('container').appendChild(table)
   }



  </script>
  </head>
  <body>
  <div id="container"></div>
  <script type="text/javascript">
   // this script strips everything after ? and puts the fields in the first td and the value in the second td
   //
   createTable();
  </script>
  </body>
</html>


-mac-
mailto:mac_doggie@hotmail.com
the Netherlands...
Thread Tree
littlemonsta Help: Get data from url and write to table on 24 Feb 2010 at 4:21 AM
mac_doggie Re: Help: Get data from url and write to table on 1 Mar 2010 at 2:04 PM
littlemonsta Re: Help: Get data from url and write to table on 2 Mar 2010 at 10:20 AM
mac_doggie Re: Help: Get data from url and write to table on 5 Mar 2010 at 11:17 AM



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.