<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<img src="loading.gif" id="img_load" height="420">
<a href="#" class="button">кнопка</a>
<a href="#" class="button">кнопка</a>
<a href="#" class="button">кнопка</a>
<a href="#" class="button">кнопка</a>
<div id="results"></div>
$(document).ready(function(){
$(".button").each(function(i,e){
$(e).bind("click",function(){set(i);});
});
set(4);
});
function set(id){
$.ajax({
type: 'POST',
url: 'index.php',
dataType: 'json',
data: { right: id },
success: function(data) {
$('#img_load').attr('src', data.src);
$('#results').text(data.validate);
$('.button').text(function(i) { return data["btn_" + (i + 1)]; });
}
});
}
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<img src="#" id="img_load">
<a href="#" name="button1" data-num="1" class="button">кнопка</a>
<a href="#" name="button2" data-num="2" class="button">кнопка</a>
<a href="#" name="button3" data-num="3" class="button">кнопка</a>
<a href="#" name="button4" data-num="4" class="button">кнопка</a>
<div class="results"></div>
<script language="javascript" type="text/javascript">
$('.button').on('click', function(e){
e.preventDefault();
var img = $('#img_load');
var current = $(this);
var buttons = $('.button');
$.ajax({
type: 'POST',
url: 'setings.php',
data: 'btn=' + current.data('num'),
success: function(data){
$('.results').html(data);
buttons.each(function(){
$(this).html( 'Кнопка ' + $(this).data('num') );
});
current.html( 'Кликнули сюда' );
img.attr('src', 'image url');
}
});
});
</script>
$array = range(1, 16);
shuffle($array);
echo implode('<br/>', array_slice($array, 0, 4));
buttons.push(painters[0]);
buttons.push(painters[1]);
buttons.push(painters[2]);
buttons.push(painters[3]);
...
document.getElementById("btn1").innerHTML = buttons[0];
document.getElementById("btn2").innerHTML = buttons[1];
document.getElementById("btn3").innerHTML = buttons[2];
document.getElementById("btn4").innerHTML = buttons[3];