$.ajax JSON not passing values on complete

Hello, I'm having an annoying issue, on complete i get undefined when trying to make simple url validation. success working fine.

i get a valid json response:

{"error":"some error"}

and this is my jQuery

$("#myform").submit(function(){
            dataString = $("#myform").serialize();
            $.ajax({
                type:       "GET",
                url:        "myform.php",
                data:       $.URLDecode(dataString), //fixing url problem
                dataType:   "json",
                beforeSend: function(){ 
                        $('#search').append('<img src="images/ajax-loader.gif" />'); //loader
                        $('.error').remove(); //removes every submit
                    }, 
                success:    function(data){
                                    $('<span class="error">' + data.error + '</span>').appendTo($('#search'));

                            },
                complete:   function(data){ 
                                $('#search img').fadeOut(); //removes loader
                                    alert(data.error);

                }

            });
            return false;  //force ajax submit
        });

Any hint please?



Bookmark and Share   Read more Read more...   Source: Stack Overflow