I need to store the data returned from a jquery $.post call in a variable called result
.
the code below works except on the first click result
comes back as undefined...
on the second click it returns the data from the php file as expected.
Thanks.
$('a').on('click',function(){
var cv = $(this).data('cv');
var url= '_php/myphp.php';
$.post(url,{contentVar:cv},function(data)
{
result = data
return result;
});
alert(result);
});