Is it possible to return only one code fragment of a page with AJAX
JQuery
?
What I want to do is:
I have a page where, through POST
, I send the ID with AJAX
, and it generates the body of a modal <div class="modal-body">
, but I would like to have another div to return the header of this modal <div class="modal-header">
.
Is there any way I can call the result of AJAX
each div
individually so that there is a change of HTML
via Javascript
?
Additional
What I have so far would be this:
<script>
function teste(){
var url = "&id="+teste;
$.ajax({
url: "conv_modal_results.php",
dataType:"HTML",
type: "POST",
data: url,
beforeSend: function(){
$('.modal-body').html('<div align="center"><img src="img/loading.gif" /></div>');
},
sucess: function(data){
setTimeout($('.modal-body').html(data),2000);
}
});
}
</script>
<input type="button" value="botaozinho" onClick="teste()">
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">Carregando....</h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Fechar</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
In conv_modal_results.php I have the following return
<div id="corpo_modal" class="row">
Aqui vai o corpo do modal...
</div>
What I want is to be able to add another div
and be able to call each one individually in the output, using something like .find()
JQuery
to use only that piece of HTML