I have tried searching solution to my problem with JQuery AJAX with
XML document. I am trying to access XML document from the Library of
Congress. The URL is:

http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&startRecord=1&maximumRecords=1&recordSchema=marcxml&query=9780020419808";

I typed the url in the browser address on Safari and Firefox. The XML
document was received as expected. Through JQuery AJAX the XML
document was never received. I wonder whether Library of Congress
could tell difference between AJAX and browser requests. What's wrong
with my code?


<html>
<head>
<meta http-equiv="content-type"content="text/html; charset=utf-8">
<title>Request Library Catalog</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
  $(function(){
    $('#update-target a').click(function(){
      $.ajax({
        type:"GET",
        url:"http://z3950.loc.gov:7090/voyager?
version=1.1&operation=searchRetrieve&startRecord=1&maximumRecords=1&recordSchema=marcxml&query=9780020419808",
        dataType:"xml",
        success:function(xml){
          alert("XML arrived.");
          $("version",xml).each(function(){
            var id_text=$(this).text();
            $('<li></li>')
              .html('version ('+id_text+')')
              .appendTo('#update-target ol');
          }); //close each(
        }
      }); //close $.ajax(
    }); //close click(
  }); //close $(
</script>
</head><body>
  <div id='update-target'>
    <a href="">Click here to load library catalog</a>
    <ol></ol>
  </div>
</body></html>

Thanks for your great help in advance!

Reply via email to