I'm very new to JQuery but am really putting forth an effort to learn more about it. I've written a function that I'm expecting a return value back from but am only getting undefined. Can someone please show me where I'm going wrong?
Here is my code.
function test(){
  $.ajax({
    url:"",
    dataType:"json",
    type:'POST',
    data:{countMedia:'true'},
    success:function(data){
return data.value;
    }
  });
}
alert(test()); // returns undefined when it should return an int value
Also, am I allowed to write a function inside of document ready? This is where I need to use it.
 
     
    