You'll need to create a hidden field on the page
<asp:hiddenfield runat="server" id="hdnReturnVal"/>
Then you store the return value in that field:
$("#hdnReturnVal").val(returnVal);
and then you can access it in the click function
var url = $("#hdnReturnVal").val();
...