<input type="text" name="id_door" style="width:200px;height:30px" >
<input id="add_pod_btn" style="margin-top:-10px;" type="button" value="Добавить">
<div id="bar_block">
<div class="bar">
<h3 class="lab_1">Alesandro</h3>
<h3 class="close_type"> X </h3>
<input type="hidden" value="1">
</div>
</div>
<script>
edit()
function edit(){
$('.close_type').click(function(){
var val_sel=$(this).parent('.bar').find('input').val();
$.ajax({
type: 'POST',
dataType:'json',
url: 'http://exportgrain.net/functions_ajax/del_pod_door/',
data:{id:val_sel},
success: function(data) {
},
error: function(xhr, str){
alert('Возникла ошибка: ' + xhr.responseCode);
}
});
})
}
$('#add_pod_btn').click(function(){
var val_sel=$(this).parent('#add_pod').find('input[name=id_door]').val();
var id_door=1;
$.ajax({
type: 'POST',
dataType:'json',
url: 'http://exportgrain.net/functions_ajax/get_name_of_door/',
data:{id:val_sel,id_door:id_door},
success: function(data) {
var sel_text=data[0].name;
edit()
$('#bar_block').append(
'<div class="bar"><h3 class="lab_1">'+sel_text+'</h3><h3 class="close_type"> X </h3> <input type="hidden" value="'+val_sel+'"></div>'
);
},
error: function(xhr, str){
alert('Возникла ошибка: ' + xhr.responseCode);
}
});
})
</script>