views:

36

answers:

1

Hi I am new to Jquery

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.

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

});

Got it working. this helped

RisingSun