Reputation: 2699
I would like to display the response of the ajax function below to a div in the dom (update div). How is this to be done without using heavy plugins.
url: 'http://dowmian.com/xs1/getcam.php',
type: 'GET',
data: {id: <?php echo $cam_id; ?>},
success: function(responseText){
},
error: function(responseText){
}
Upvotes: 4
Views: 8158
Reputation: 10221
It depends on the return value of your getcam.php
function, but you're probably looking for the html()
function:
$.ajax({
url: 'http://dowmian.com/xs1/getcam.php',
type: 'GET',
data: {id: <?php echo $cam_id; ?>},
success: function(responseText){
$('#update-div').html(responseText);
},
error: function(responseText){
}
});
If you want to append the #update-div
dynamically, as in just before the ajax-call, you can do this with append()
:
$('.container').append($('<div/>').attr('id','update-div'));
References:
Upvotes: 5
Reputation: 13250
try this:
success: function(responseText) {
$("#update-div").text(responseText.d);
},
You can get more info from here
Upvotes: 0
Reputation: 13205
Inside success, do this:
success: function(responseText) {
$("#target").text(responseText);
},
Upvotes: 1