function myFunction(p1, p2) { var a = ""; $.post( "/url", function( data ) {a = data.result;}); return a; }