1function myFunction(p1, p2) {
2 var a = "";
3 $.post( "/url", function( data ) {a = data.result;});
4 return a;
5}
1function myFunction(p1, p2) {
2 var a = "";
3 $.ajax({
4 method: "POST",
5 url: "/url",
6 data: {p1: p1,p2: p2},
7 success: function (data) {a = data.result;},
8 error: function (data) {a = data.result;}
9 });
10 return a;
11}
1function add(a, b) {
2 return a + b; //Return stops the execution of this function
3}
4
5var sum = add(5, 24); //The value that was returned got but inside the variable sum