I've tried many things to fix this.

In the error alert box I get:
[{"id":"827","make_id":"96","name":"tC"},
{"id":"825","make_id":"96","name":"xA"},
{"id":"826","make_id":"96","name":"xB"},
{"id":"828","make_id":"96","name":"xD"}]

Which is correct.

$(function(){
        $("input.search").keypress(function(){

                $("select.make").removeAttr('disabled');
                $("button.search").removeAttr('disabled');

        });

        $("select.make").each(function(i){
                $(this).change(function(){

                        var make_id = $(this).val();
                        var select_models = $("select.model")[i];

                        if(make_id > 0) {
                                $.ajax({
                                        type: "POST",
                                        url: "/request.php",
                                        data: {action: "model_list", make_id: 
make_id},
                                        dataType: "json",
                                        success: function(models) {
                                                select_models.empty();

                                                $(models).each(function(ii){
                                                        
select_models.append('<option value="' + $(this)['id'] + '">' +
$(this)['name'] + '</option>');
                                                });

                                                
select_models.removeAttr('disabled');
                                        },
                                        error: function(object, msg) {
                                                alert(object.responseText);
                                        }
                                });
                        }

                });

        });
});

Reply via email to