Return from jQuery Ajax Method
<p>I have a button named searchReportButton. On this button click, I need to check session value from server using a ajax web method "Error.aspx/CheckSessionExpiry".This is done in checkSession javascript function. The checkSession is not returning anything now - instead it is handling the required operation based on the result (redirecting to error page).</p>

<ol>
<li>I need to return the result of ajax web method to the Main Caller.  How can we do this return?</li>
<li>Do I need to move the remaining code (from Main Caller) into sucsess callback?</li>
</ol>

<p><strong>Main Caller</strong></p>

<pre><code>searchReportButton.click(function () {

    checkSession();
    //Remainging Code

});
</code></pre>

<p><strong>Helper</strong></p>

<pre><code>function checkSession() {

var win = 101;
$.ajax(
        {
            type: "POST",
            url: "Error.aspx/CheckSessionExpiry",
            data: '{"winNumber": "' + win + '"}',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: handleSessionResult

        }
        );
        }
</code></pre>

<p><strong>Result Helper</strong></p>

<pre><code>  function handleSessionResult(result) {


    if (result.hasOwnProperty("d")) 
    {
      result = result.d
    }

    if (result == "ACTIVE") 
    {
      window.location.href("Error.aspx");
      return false;
    }

   //alert(result);
</code></pre>

<p>}</p>

<p>REFERENCE:</p>

<ol>
<li><a href="http://stackoverflow.com/questions/5097191/ajax-context-option/5097214#5097214">$.ajax context option</a></li>
<li><a href="http://stackoverflow.com/questions/13670564/jquery-ajax-callback-does-not-get-context">jQuery Ajax Callback does not get Context</a></li>
<li><a href="http://stackoverflow.com/questions/939032/jquery-pass-more-parameters-into-callback">JQuery pass more parameters into callback</a></li>
</ol>
