Ajax请求每个循环

function cherchePhoto(motcle) {
            var url="http://api.flickr.com/services/feeds/photos_public.gne?tags="+motcle+"&tagmode=any&format=json&jsoncallback=?";

            // Appel AJAX
            $.ajax({
                url:url,
                type: 'GET',
                dataType: 'json',
                success : function(){
                    $('#images').empty();
                    $.each(data.items, function(i,item){
                        $(document.createElement('img')).attr('src', item.media.m).appendTo("#images");

                    });
                }
            })  
}

I have this jQuery function with an ajax call and I want to build a img tag with the src attribute after #images in my html page for each images I receive from the ajax call. But I get an uncaught reference error with 'data' not defined, why ?

Because you missed data in your success callback. Try this

success : function(data){

i think its because you missed to inform data inside your callback function. you will need something like this:

function cherchePhoto(motcle) {
        var url="http://api.flickr.com/services/feeds/photos_public.gne?tags="+motcle+"&tagmode=any&format=json&jsoncallback=?";

        // Appel AJAX
        $.ajax({
            url:url,
            type: 'GET',
            dataType: 'json',
            success : function(data){
                $('#images').empty();
                $.each(data.items, function(i,item){
                    $(document.createElement('img')).attr('src', item.media.m).appendTo("#images");

                });
            }
        })

    }

You need to define data as the first argument of the success function.

function cherchePhoto(motcle) {
         var url="http://api.flickr.com/services/feeds/photos_public.gne?tags="+motcle+"&tagmode=any&format=json&jsoncallback=?";

        // Appel AJAX
        $.ajax({
            url:url,
            type: 'GET',
            dataType: 'json',
            success : function(data){
                $('#images').empty();
                $.each(data.items, function(i,item){
                    $(document.createElement('img')).attr('src', item.media.m).appendTo("#images");

                });
            }
        })
}