getting null value in function variable that assign in ajax success function in javascript : <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>    function getData(url) {
        var responseData = null;
        $.ajax({
          type: "GET",
          url: url,
          crossDomain: true,
          async: false,          
          contentType: "application/json; charset=utf-8",
          dataType: "jsonp",
          success: function (result) {
            responseData = result;
          }
        });   
         console.log(responseData); 
         return responseData;
      }    
     var  getapidata= getData('https://jsonplaceholder.typicode.com/todos/1');
        console.log('getapidata',getapidata);</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
</div>
</div>
</p>
