Hy guys, im new in jQuery ;)
My problem is the autocomplete plugin:
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/

It works very well and i'll find it much usefull, but i got a problem
with it..
Using the remote procedure (ajax requests), if the returning value
from the script is a string containing a Json object, IE completely
fall to parse the array (while firefox and others browser obviously do
it correctly).

The error occour even in the official demo page:
http://jquery.bassistance.de/autocomplete/demo/json.html (try to digit
everything that return an string, as 'pe')

Can anyone help me?
The error reported by the ie 'debugger' is:

Message: 'name' is null or not object
Line: 25
Char: 5
Code: 0
URI: http://jquery.bassistance.de/autocomplete/demo/json.html


Now, the strange thing is that i implemented this in my script, and it
fall both with IE and Firefox just when i type some strings, for
example works perfectly with 'john' but fail with 'new '.

Did anyone get those errors before?

My code is:


----------------------------------------------
$('input#contact-list').autocomplete('test-db.php', {
    multiple: false,
    dataType: "json",
    width: 400,
    scrollHeight: 300,
    max: 25,
    parse: function(data) {
        return $.map(data, function(row) {
            return {
                data: row,
                value: row.azienda,
                result: row.azienda
            }
        });
    },
    formatItem: function(item) {
        return item.azienda + '<br />' + item.nome + ' ' +
item.cognome + '<br />' + item.email;
    }
}).result(function(e, item) {
    //this will be triggered when the selection has made
    $.ajax({
        type: "POST",
        cache: false,
        data: "idAzienda=" + item.id_azienda + "&idReferente=" +
item.id_user,
        url: "test-db-02.php",
        success: function(message){
            //fillup the form fields
            $("input[rel='ship']").attr("readonly", true).css
("background-color", "#DFDFDF");
            $("input[rel='company']").attr("readonly", true).css
("background-color", "#DFDFDF");
            var rd = json_parse(message);
            $("input#ship-nome-referente").val(rd.company.nome);
            //[...]

            $("div#selected-contact").html(rd.company.codice + ' - ' +
rd.company.azienda + ' | ' + rd.company.nome + ' ' +
rd.company.cognome);

            $("div#contact-list-selected").css("display", "inline").css
("visibility", "visible");
            $("div#contact-list-container").css("display", "none").css
("visibility", "hidden");

            $("div#deselect-contact").click(function(){
                $("div#selected-contact").html('');
                $("input#contact-list").val('');

                $("input[rel='ship']").attr("readonly", false).css
("background-color", "#FFFFFF").val('');
                $("input[rel='company']").attr("readonly", false).css
("background-color", "#FFFFFF").val('');

                $("div#contact-list-container").css("display",
"inline").css("visibility", "visible");
                $("div#contact-list-selected").css("display",
"none").css("visibility", "hidden");
            });
        }
    });
});
----------------------------------------------

An example of my Json returned by the php script can be:

[{
    azienda: "company_name",
    codice: "company_code",
    nome: "user_name",
    cognome: "user_surname",
    email: "user_email",
    id_user: "user_id",
    id_azienda: "company_id"
},
{
    azienda: "company_name",
    codice: "company_code",
    nome: "user_name",
    cognome: "user_surname",
    email: "user_email",
    id_user: "user_id",
    id_azienda: "company_id"
},
{
    azienda: "company_name",
    codice: "company_code",
    nome: "user_name",
    cognome: "user_surname",
    email: "user_email",
    id_user: "user_id",
    id_azienda: "company_id"
}]

Reply via email to