| | |
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
![]() |
•
•
Join Date: Feb 2009
Posts: 11
Reputation:
Solved Threads: 0
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)
<div>
javascript Syntax (Toggle Plain Text)
<html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <script type="text/javascript"> xmlFile = "data.xml"; /* URL of XML File. Must be on the same domain */ $(function() { $.ajax({ type: "GET", url: xmlFile, dataType: "xml", success: function(xml) { $('.load').hide('fast'); $(xml).find('div').each(function(){ $('<li></li>') .html($(this).html()); .appendTo('#news'); }); } }); }); </script> </head> <body> <ul id="news"> <li class="load">Please Wait. Loading...</li> </ul> </body>
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
CodeJoust! Design + Development - Proud User of Ubuntu
![]() |
Similar Threads
- sending sms using vb.net (VB.NET)
- DSL Cannot Access Hotmail or Yahoo! (Networking Hardware Configuration)
- Wanted: High quality text links. (Ad Space for Sale)
- Chargeback Software & Overseas Customers (eCommerce)
- Hacktool.Rootkit virus, round 2! (Viruses, Spyware and other Nasties)
- Fake windows security and ballon msgs (Viruses, Spyware and other Nasties)
- Please help me with PR of my site (Search Engine Optimization)
- Range Of Long?? (C++)
- Adding data to print job (Visual Basic 4 / 5 / 6)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: Display nothing - please help...
- Next Thread: validate with help text
| Thread Tools | Search this Thread |
acid2 ajax ajaxexample ajaxjspservlets array browser bug captchaformproblem cart checkbox child class close codes createrange() css cursor date debugger decimal dependent design disablefirebug dom dropdown editor element embed engine enter error events explorer ext file firefox focus form forms frameworks getselection google gxt hiddenvalue highlightedword hint html ie7 ie8 iframe images index internet java javascript javascripthelp2020 jquery jsf jsfile jsp jump libcurl listbox maps masterpage math media menu mp4 object onmouseoutdivproblem onmouseover onreadystatechange parent paypal pdf php position post problem programming progressbar prototype redirect runtime safari scale scriptlets scroll search security shopping size software toggle unicode w3c web wysiwyg \n





