jQuery cant use variable in main scope
<p>i have <code>user_permissions</code> variable and i defined that for global use , after setting this on post method i dont have problem for print that, but after using this variable in many line  below i get <code>null</code> result ???</p>

<p><strong>jQuery</strong>(minimal code):</p>

<pre><code>var user_permissions = null;
    $(document).ready(function(e) {
                $.post('model/controller.php' ,{ username:iId_username , postaction:'getUserPermission' }, 
                        function(data){
                            user_permissions=0;
                            user_permissions = data.user_permissions;
                            console.log(user_permissions); // RESULT is : {"user_permissions":"8"}
                },'json');
                $.each(listPermissions, function(i, item) {
                        if ( user_permissions == listPermissions[i].id ) selected = "selected='selected'"; else selected = '';
                        console.log(user_permissions); // RESULT is : null
                        selectElement += "&lt;option value='" + listPermissions[i].id + "' "+ selected + "&gt;" + listPermissions[i].permission_title + "&lt;/option&gt;";
                });

});
</code></pre>

<p>whats my code problem?</p>
