Cannot get duplication of screens to work with mini display between iMac & Macbook
The problem is that you need to use a Thunderbolt Cable to use your iMac in Target Display Mode.  From Apple's website:



From your original question, you mention that you purchased a "mini display" which I can only deduce is that you meant that you bought a "mini Display Port cable."  If this is in fact the case, it's the wrong cable; which is why it's not working.