views:

91

answers:

1

This code works in firefox but not IE. Any ideas? I'm using the latest jQuery-ui libraries.

<!DOCTYPE html>
 <html lang="en">
<head>
<meta charset="UTF-8" />
<title>jQuery UI Autocomplete Remote datasource demo</title>
<link type="text/css" href="jquery.ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="jquery-1.4.2.js"></script>
<script type="text/javascript" src="jquery.ui.core.js"></script>
<script type="text/javascript" src="jquery.ui.widget.js"></script>
<script type="text/javascript" src="jquery.ui.position.js"></script>
<script type="text/javascript" src="jquery.ui.autocomplete.js"></script>
<link type="text/css" href="demos.css" rel="stylesheet" />
<style type="text/css">
.ui-autocomplete-loading { background: white url('images/ui-anim_basic_16x16.gif')       right center no-repeat; }
 .ui-autocomplete {
  overflow-y: auto;
  max-width: 400px;
 }
 /* IE 6 doesn't support max-width
  * we use width instead, but this forces the menu to always be this wide
  */
 * html .ui-autocomplete {
  width: 400px;
}
</style>
<script type="text/javascript">

$(function() {
 function log(message) {
  $("<div/>").text(message).prependTo("#log");
  $("#log").attr("scrollTop", 0);
 }

 $.ajax({
  url: "links2.xml",
  dataType: "xml",
  success: function(xmlResponse) {
   var data = $("ROW", xmlResponse).map(function() {
    return {
      value: $("SC_DF_FIELD_1", this).text(),
      url: $("SC_DF_FIELD_2", this).text(),
      support_url: $("SC_DF_FIELD_3", this).text(),
      description: $("SC_DF_FIELD_4", this).text(),
      contact: $("SC_DF_PERSON_LINK", this).text()

    };
   }).get();

   $("#_results").autocomplete({
    source: data,
    minLength: 0

   }).data( "autocomplete" )._renderItem = function( ul, item ) {
   return $( "<li></li>" )
   .data( "item.autocomplete", item )
   .append( "<a>" + item.value + "<br>" + item.url + "<br>" + item.description + "<br>" + "Support URL: " + item.support_url + "<br>" + "Contact: " + "<a href=" + item.contact + ">Test</a>" + "<br />" + "</a>" )
   .appendTo( ul );
 }

  }
 })

});
</script>

Search:

A: 

The code works for me in IE. The only difference I see is that I'm using the googleapis version of jquery and jqueryui:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.js"&gt;&lt;/script&gt;

The only other possible difference is the markup since you didn't post yours. I just have an input like this:

<input type="text" id="_results" />
fehays
In chrome I see that I am getting a "Origin null is not allowed by Access-Control-Allow-Origin" error Changing my source to the googleapi doesn't fix it in IE or chrome. I still get the same error in chrome.
specked
I am also using the same input
specked
That's strange. That error sounds like a cross-domain ajax error. But I don't know why it would work in FF if that were the problem. Is the links2.xml file on the same domain as your page that's doing the ajax?
fehays
I'm doing all of this on my local machine, all files are located in the same directory. I based this off of the xml example bundled with jQuery-ui. Interestingly enough their example has the same error and only works in FF.
specked
Looks like that running this locally is the problem. Thanks for the hint fehays
specked