0

I am using jquery ui autocomplete, and from the bug i get in ie7 it sounds like jquery 1.10.2 or 1.11.3 are both failing the ajax call.

I wonder if anyone knows any workaround that ?

EDIT1

The code work with all other browsers and with IE10+ I have traced the problem to the following part of jquery.

for ( ; list && firingIndex < firingLength; firingIndex++ ) {
    if ( list[ firingIndex ].apply( data[ 0 ], data[ 1 ] ) === false && options.stopOnFalse ) {
     memory = false; // To prevent further calls using add
     break;
    }
   }

My Code never reach success, and it always goes into the error function. I can't tell why. I believe this is the code that cause it.

Edit2: Here is my code.

<html>

<head>

  <script src="jquery-ui-1.11.4/external/jquery-1.10.2/jquery-1.10.2.js"></script>
  <!--<script src="//code.jquery.com/jquery-1.10.3.js"></script>-->
  <script src="jquery-ui-1.11.4/jquery-ui.js"></script>
  <script src="jquery.base64.js"></script>
  <script src="jquery-ui-1.11.4/plugins/jquery.ui.autocomplete-html.js"></script>
  <script src="PoolPartyAutoCompleteSetter.js"></script>
  <link rel="stylesheet" href="jquery-ui-1.11.4/jquery-ui-modified.css">


  <link rel="stylesheet" href="brik.css">
  <!--Will be supplied by BRIK-->

  <script>
    function select(event, ui) {

      $(this).val('')
      alert(ui.item.mydata.uri)
      return false
        //alert(JSON.stringify(ui.item.mydata))
    }

    $(document).ready(function() {

      set_autocomplete($, select, $("#search_topics"), "dc_subject")
    });
  </script>


</head>





<body>

  <div>
    <div id="topics">Topics
      <input id="search_topics" class="submit-text" type="text"></input>
    </div>
  </div>

</body>

</html>

function set_autocomplete($, select, $input, field) {

  switch (field) {
    case "dc_contributor_author":

      var scheme = "http://thesaurus.iadb.org/publicthesauri/IdBAuthors";
      break;

    case "dc_subject":

      var scheme = "http://thesaurus.iadb.org/publicthesauri/IdBTopics";
      break;

    case "iadb_department":

      var scheme = "http://thesaurus.iadb.org/publicthesauri/IdBDepartments";
      break;

    case "dc_contributor_institution":

      var scheme = "http://thesaurus.iadb.org/publicthesauri/IdBInstitutions";
      break;

    case "dc_identifier_jel":

      var scheme = "http://thesaurus.iadb.org/jelcodes/IdBJelCodes";
      break;

    default:

      var scheme = "http://thesaurus.iadb.org/publicthesauri/IdBCountries";

  }

  $input.autocomplete({

    source: function(request, response) {

      var hint = request.term;

      $.ajax({

        url: "http://thesaurus.iadb.org/extractor/api/suggest",

        data: {
          projectId: "1DCE4EC2-E3AB-0001-A09D-1BC01E70CE80",
          language: "en",
          searchString: request.term,
          numberOfConcepts: 1000
        },


        dataType: 'json',

        crossDomain: true,


        beforeSend: function(req) {
          if (!window.btoa) window.btoa = $.base64.btoa;
          req.setRequestHeader('Authorization', 'Basic ' + btoa('xxxxx:xxxxx'));
        },

        /*xhrFields: {
            withCredentials: true
        },*/

        error: function(jqXHR, textStatus, errorThrown) {
          response(textStatus)
        },

        success: function(data) {

          var datatable = Array();

          for (i = 0; i < data.suggestedConcepts.length; i++) {

            if (scheme == data.suggestedConcepts[i].conceptSchemes[0].uri) {


              datatable.push({
                label: hintHighlight(data.suggestedConcepts[i].prefLabel, hint),
                value: data.suggestedConcepts[i].prefLabel,
                mydata: data.suggestedConcepts[i]
              })

            }

          }


          response(datatable.slice(0, 13).sort(function(a, b) {

            if (a.label.toLowerCase() == b.label.toLowerCase())
              return 0;
            if (a.label.toLowerCase() > b.label.toLowerCase())
              return 1;
            else
              return -1

          }));
        }
      })
    },

    minLength: 2,

    select: select,


    html: true,

    open: function() {
      $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
    },
    close: function() {
      $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
    }
  }).autocomplete("instance")._renderMenu = function(ul, items) { // Render different background for even and odd line of the menu
    var that = this;
    $.each(items, function(index, item) {
      that._renderItemData(ul, item);
    });
    $(ul).find("li:odd").addClass("ac_odd");

  }
}



function hintHighlight(sentence, hint) {



  var reg = new RegExp(hint, "gi");

  var matches = sentence.match(reg)

  if (matches == null)
    return sentence;

  var highlighted = sentence;

  for (var i = 0; i < matches.length; i++) {

    highlighted = highlighted.replace(matches[i], "<strong class = \"ac_highlight\">" + matches[i] + "</strong>")
  }

  return highlighted;
}

EDIT3

I have traced it to the following code in Jquery

// Get transport
  transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );

  // If no transport, we auto-abort
  if ( !transport ) {
   done( -1, "No Transport" );
  } else {
   jqXHR.readyState = 1;

   // Send global event
   if ( fireGlobals ) {
    globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
   }
   // Timeout
   if ( s.async && s.timeout > 0 ) {
    timeoutTimer = setTimeout(function() {
     jqXHR.abort("timeout");
    }, s.timeout );
   }

Transport is always undefined. Best

MaatDeamon
  • 9,532
  • 9
  • 60
  • 127
  • what issue you are facing? Have you tried with newer version of jquery? – Parth Trivedi Jan 07 '16 at 05:16
  • newer version of ? I am bound to support IE 7 because it is a website of the intranet of the organization i work in, can't change the compatibility mode. – MaatDeamon Jan 07 '16 at 05:20
  • What version of jQuery UI are you using? – jfriend00 Jan 07 '16 at 05:29
  • I use the version 1.11.4 – MaatDeamon Jan 07 '16 at 05:30
  • In the jQuery code having the problem, what is the value of `options.dataTypes[ 0 ]` and of `transports` as passed into the `inspectPrefiltersOrTransports()` function? The issue looks to be something with `dataTypes` or `transports`. – jfriend00 Jan 07 '16 at 06:56
  • I solve the problem by not solving it. In my organization we have Internet explorer 11. But the IT team has put a default of compatibility mode on our IE. So i have just added the metadata tag that tell IE to work in Mode 10. Problem solved – MaatDeamon Jan 10 '16 at 00:55

1 Answers1

1

jQuery 1.x does support IE7. jQuery UI 1.11.x does not support IE7.


Here's the link to jQuery's browser support: https://jquery.com/browser-support/.

Per that chart, jQuery 1.x works with IE6+ so it should work with IE7.


Here's the link to jQuery UI's browser support: https://jqueryui.com/browser-support/

Per that chart, jQuery UI 1.11.x requires IE8 or higher.

That same page says this about older browsers:

While jQuery UI might run without major issues in older browser versions, we do not actively test jQuery UI in them and generally do not fix bugs that may appear in them.

So, you are not guaranteed jQuery UI support in IE7. If you want us to help you diagnose exactly what the code issue is, you would have to include the actual code causing the problem in some way that we could run it and see if we could find a work-around.

jfriend00
  • 683,504
  • 96
  • 985
  • 979
  • I will Edit my Question – MaatDeamon Jan 07 '16 at 05:28
  • @MaatDeamon - Here's a discussion of issues with jQuery UI's autocomplete on IE7: https://forum.jquery.com/topic/jquery-ui-autocomplete-problems-on-ie-6-and-ie-7. One user in that thread did find a work-around. – jfriend00 Jan 07 '16 at 05:33
  • @MaatDeamon - More discussion of the issue here: [Problem with jquery.ui.autocomplete.js on IE7](http://stackoverflow.com/questions/1267200/problem-with-jquery-ui-autocomplete-js-on-ie7). – jfriend00 Jan 07 '16 at 05:37
  • Thanks, i have added my code, as suggested. I will take the time to read your links. Although feel free if you have any more comments. Thanks so far – MaatDeamon Jan 07 '16 at 05:43
  • Sounds like none of those comment are actually helping me to my dismay :(. The error i get is different. The problem in my case is that jquery always goes into the error function. Then the bug is not in jquery but in jquery uri because it can not handle the error function results. However that is a second issue. The first issue to solve is why do i go into error all the time – MaatDeamon Jan 07 '16 at 05:53
  • @MaatDeamon - what does it say the error is when it goes into the error handler? One of those work-arounds were because IE7 was not processing a JSON result properly so they had to switch to their own JSON parsing to avoid a JSON parsing error. – jfriend00 Jan 07 '16 at 06:02
  • It says "No Transport". I have also added the piece of code in jquery that is causing that as a new edit. – MaatDeamon Jan 07 '16 at 06:14
  • Here's discussion of ways to work-around the "No Transport" error in IE: http://stackoverflow.com/questions/5241088/jquery-call-to-webservice-returns-no-transport-error, http://stackoverflow.com/questions/15418290/ajax-post-request-on-ie-fails-with-error-no-transport and http://stackoverflow.com/questions/9160123/no-transport-error-w-jquery-ajax-call-in-ie. – jfriend00 Jan 07 '16 at 07:00
  • I solve the problem by not solving it. In my organization we have Internet explorer 11. But the IT team has put a default of compatibility mode on our IE. So i have just added the metadata tag that tell IE to work in Mode 10. Problem solved – MaatDeamon Jan 10 '16 at 00:54