3

I am trying to get the Jquery UI autocomplete working on AJAX loaded dynamic fields in div #right

I do not fully understand the code below.

$("#right").delegate(".drugName", "focus", function(){

 //attach autocomplete
$(".drugName").autocomplete({

 //define callback to format results
 source: function(req, add){

  //pass request to server
  $.getJSON("druglist.php?callback=?", req, function(data) {

   //create array for response objects
   var suggestions = [];

   //process response
   $.each(data, function(i, val){        
    suggestions.push(val.name);
   });

   //pass array to callback
   add(suggestions);
  });
 },

 });

});

But it works in Chrome/FF. However it seems to be killing AJAX loading in Internet Explorer causing the application to be non - functional

The error returned is

   SCRIPT1028: Expected identifier, string or number  ajaxfunctions.js, line 41 character 6

The error in the console refers to the brackets on the second last row.

I tried to work this out using the documentation, but couldnt get it to work :-(

Whats happening with the code & IE?

Pls help.

1 Answer 1

2
//pass array to callback
 add(suggestions);
 });
}, //OK the comma here was the problem

});

Got it working. this helped

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.