Simplifying an ajax script in my HTML
Depending on when you want to make the ajax request, you'll need to modify the first line of my example. Currently it just gets all of them. You might want to change it so that it gets only the div that was clicked, or whatever. Anyways here's one way you could do that:

$('div[id*="carousel"]').each(function() { //The *= selector gets all the divs with an id that contains carousel anywhere in the id.
    var $this = $(this), //Here we select the right div
        id = $this.attr('id'); //And grab the id of the div

    $.ajax({
        url: 'json/' + id,
        //You don't need to set type: GET, the GET is the default.
        success: function(data) {
            //blah blah blah...
            $this.append(d); //Boom done!
        }
    });
});


The way you have your success function set up, you're appending and changing the DOM each time that for loop goes around, and it goes around for every image. That's not good because DOM manipulations are quite expensive performance wise. So if you have 100 images, you're append one at a time - 100 times. The better way to do that would be do all your stuff and save to a variable, string, or object, then append once outside the loop.

Here's an example of what  I mean:

var totalPictures = data['totalPictures'],
    d = ""; //We add "d" outside

for (var i=0; i&lt;totalPictures; i++) {
    if(i&lt;1){
        d = "&lt;div class='item active'&gt;";
        d += "&lt;a href='" +data.pictures[i]['photo'] +"' rel='prettyPhoto'&gt;";
        d += "&lt;img src='" +data.pictures[i]['photo'] +"' &gt;";
        d += "&lt;/a&gt;";
        d += "&lt;/div&gt;";
    } else {
        d += "&lt;div class='item'&gt;"; //Added a += here so that it'll add onto the first picture
        d += "&lt;a href='" +data.pictures[i]['photo'] +"' rel='prettyPhoto'&gt;";
        d += "&lt;img src='" +data.pictures[i]['photo'] +"' alt=''&gt;";
        d += "&lt;/a&gt;";
        d += "&lt;/div&gt;";
    }
}

$('#carousel1b').append(d); //Here we append a single time outside the loop
//This cuts our appends down from totalPictures to 1.
//What may seem like a small change will make a huge difference

$("a[rel^='prettyPhoto']").prettyPhoto(); //I assume you'll need this outside since it depends on the appended content