Generally, you cannot ping an AP as it is a layer 2 device, this means it operates at the datalink layer. This layer will not respond to ICMP echos.
In the layer the only way to know if the AP is working is to see if you can ping your next hop (generally your gateway). To check the AP specifically you want have to find out in a layer two manner if there is a traffic coming to you.
Note: If you can associate with the AP it generally means the AP is OK.
However, to check if your AP is working correctly. First find out your AP's SSID (MAC address) via
iwlist. After doing so run a
tcpdump and check to make sure you are getting packets from the SSID to your computer's MAC address.
tcpdump -i wlan0 -e -nn 'ether src XX:XX:XX:XX:XX:XX && ether dst FF:FF:FF:FF:FF:FF'
By seeing this traffic you will see that you are recieving traffic from the AP and you are associated properly.
tcpdump -i wlan0 -e -nn 'ether src XX:XX:XX:XX:XX:XX && ether dst YY:YY:YY:YY:YY:YY'
Replace the XXs with the MAC address of the AP (the SSID) and the YYs with the MAC address of your wireless interface. If you see traffic here, you know that the AP is specifically sending traffic to your wireless interface, which shows more conclusively what you are connected.
This answer assumes you are trying to make sure that the error you are having is with a connection to an AP.
If you want something different - i.e. a NetworkManager-like application which will connect to any available SSID, add that to your question.