A function triggers a database call which returns some Json. This CID is then used to stamp the newly added DOM element.
I need to retrieve / return the value of "cid" which exists within ajax success block, it will be used to update attribute.
Error cid is not defined
//Save New Task
$("body").on('click','.icon-facetime-video',function(event){
  var new_entry = $(this).prev().val();
  var thebid = $(this).parents('tbody').prev().find('th').attr('id').split('_')[1];
  $(this).parent().addClass('tk').html('<i class="icon-eye-open"></i> '+new_entry);
  //CALL FUNCTION
  var cid = update_entry('new_tk',new_entry,thebid); //value of cid from update_entry
  $(this).parent().attr('id','cid_'+cid);
});
function update_entry(typeofupdate,new_entry,thebid){
  switch(typeofupdate){
    case 'new_tk': var action = 'new_tk';
    break;
  }
  $.ajax({
        type:'post',
        url: 'posts_in.php',
        dataType: "json",
        data: {cid : thebid, action: action, content: new_entry},
        success: function(data){
            var action = data[0],cid= data[1];
            console.dir(data);
        }
    });
  return cid;  
}
 
    