$catlistThis is a jQuery POST using AJAX:
$(document).ready(function() {
$('#taglist').change(function(){
$.post('../includes/ajax.php', { taglist: $(this).find("option:selected").attr('value')}, function(data) {
$("#catid").html(response.catlist);
});
});
});
And this is is what happens in ajax.php:
if(isset($_POST['taglist'])){
$catlist = '<select name="cat_id[]" size="5" multiple id="cat_id[]" class="darkgrey w200px">';
$catlist .= '<option value="123">123</option>';
$catlist .= '<option value="456">456</option>';
$catlist .= '</select>';
echo json_encode(array("status"=>"success", "catlist" => $catlist));
}
In my real page I will be populating the cat_id select with values depending on the POST. For testing purposes I’m just returning a static select with 2 options.
For some reason I cant grasp, I can’t seem to get the response to appear inside #catid although the post and response are carried out fine (I’m using the Firebug Net panel for monitoring the Post and Response). Please give me your lights on this.
I have noticed that you have no echo related to variable $catlist
should be some thing like
And you AJAX response code should be updated
replaced with
EDIT: I exactly haven’t got what exactly your problem is after above solution but one i thing I can guess is you might be having issue due to json encode you have made on server side in php for that you have to have following chnages in your code.