using AJAX to get only relevant info

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Reply

Join Date: Feb 2009
Posts: 11
Reputation: NetMyMate is an unknown quantity at this point 
Solved Threads: 0
NetMyMate NetMyMate is offline Offline
Newbie Poster

using AJAX to get only relevant info

 
0
  #1
Jul 7th, 2009
I have a large xml file which contains news, articles, reviews, etc. I wanna use AJAX and get only news displayed in a
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <div>
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 178
Reputation: codejoust is an unknown quantity at this point 
Solved Threads: 18
codejoust's Avatar
codejoust codejoust is offline Offline
Junior Poster

Re: using AJAX to get only relevant info

 
0
  #2
Jul 7th, 2009
  1. <html>
  2. <head>
  3. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
  4. <script type="text/javascript">
  5. xmlFile = "data.xml"; /* URL of XML File. Must be on the same domain */
  6. $(function() {
  7. $.ajax({
  8. type: "GET",
  9. url: xmlFile,
  10. dataType: "xml",
  11. success: function(xml) {
  12. $('.load').hide('fast');
  13. $(xml).find('div').each(function(){
  14. $('<li></li>')
  15. .html($(this).html());
  16. .appendTo('#news');
  17. });
  18. }
  19. });
  20. });
  21. </script>
  22. </head>
  23. <body>
  24. <ul id="news">
  25. <li class="load">Please Wait. Loading...</li>
  26. </ul>
  27. </body>
-- jQuery to do that...
Change the url in the script (the ajax url), and it should work.
The code was adopted from http://www.xml.com/pub/a/2007/10/10/jquery-and-xml.html
Good Luck!
Last edited by codejoust; Jul 7th, 2009 at 4:09 pm. Reason: Messed up BBcode Tags
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC