javascript waiting for return before proceeding
<p>I have an issue with my javascript not waiting for the return of the call. I already now that javascript is asynchronous so I would like to know how to make this method call wait for the result. I do not have control over the first two snipper since they are uploaded by the user. I can use jquery or pure javascript. Advance thanks!</p>

<p>I have this javascript call</p>

<pre><code>var value = somemethod("cmi.location");
/ /This is not getting set since it does not wait. alerts 'undefined'
alert(value);
</code></pre>

<p>and somemethod looks something like the code below,</p>

<pre><code>function somemethod(element){
var result;
result = API1.GetValue(element);
return result;
}
</code></pre>

<p>API is a window object instantiated by doing the code below. I have access to the code snippets from this point on.</p>

<pre><code>var API1 = new API();
</code></pre>

<p>API is an object in javascript which looks like this:</p>

<pre><code>function API(){

};
API.prototype.GetValue=API_GetValue;

function API_GetValue(parameter){
$.ajax({
    type:"POST",
    async:false,
    url:"method.do",
    dataType:"xml",
    data: {action: 'getValue', parameter: parameter, value: ''},
    success:function(data){
    //I am getting 0 here
        return $(data).find('search').text();
    }
});
}
</code></pre>
