I have a JQuery-Code like this:

```
    $.post("count_images.php",{}, function(data)
    {
        if (data != '')
        {
            alert(data);
        }
        else
        {
            //Error
        }
    });

```

It simply sends a request to `count_images.php` and returns a number like `23` for example. This works perfectly fine, but when i change it into this:

```
    var number_images;

    $.post("count_images.php",{}, function(data)
    {
        if (data != '')
        {
            number_images = data;
        }
        else
        {
            //Error
        }
    });

    alert(number_images);

```

It does not work correctly. The alert-function always outputs an `undefined`. I simply want to save the result saved in `data` in a variable called `number_images` so i can keep on working with that. Thank you very much in advance.