this is probably something very simple to fix. Im posting to a php page that returns the ID of the new element created in the db- (posting via $.ajax)- i have logged the returned value.
The following code is the code i use to post
$.ajax({
type: "POST",
url: "<?=base_url()?>events/add_tag_js/",
data: url,
success: function(html){
$("#tag_list").append('<li><span id="" class="tag">'+formvalue+'<span class="remove_tag"><a class="remove_tag_link" href="#">x</a></span></span></li>');
$("#add_tag").val('');
console.log(html);
},
failure: function(){
$('.error').show();
$("#add_tag").val('');
}
});
The return value from the console.log is
{"error":false,"msg":"Tag added","id":44}
but when i do alert(html.id) i get undefined? do i need to parse the json returned to do this? or is my json incorrect?