Back in the 19th century Europe witnessed the rise of two influental ideologies: pan-Germanism, and, as a response to it, pan-Slavism.
Pan-Germanism was about the unification of German lands, was the result of the shock the German states experienced in their rapid subjugation by Napoleon's force, where the cultural similarity between German states and the cultural difference from the French occupier became very pronounced. Then in the 1820s and 1830s pan-Germanism, buoyed by the development of Indo-European lingustics where ancient Germanic texts (the Edda, Beowulf, the Nibelungslied) were widely disseminated and analysed and when the considerable antiquity of underlying traditions and their similarity to the more prestigious Greek and Sanskrit texts became obvious, started including other Germanic peoples (English, Dutch, Danish, Swedish, Norwegian, Icelandic etc.) as possible members of a future Germanic community or state.
The only people among which pan-Germanism, in both the narrower and wider sense, became very popular were Germans. It was also received with some enthusiasm among Norwegians. In the other Germanic countries it failed to gain almost any following, in some cases becauses the people more readily identified with Celtic than Germanic heritage (the English), or were suspicious of German intentions (the Dutch, the Danish), or were simply indifferent (the Swedish, the Icelandic).
As an alternative Denmark began promoting pan-Scandinavism, to strengthen her own position vis a vis the Germans' demographic, military and economic superiority.
Pan-Slavism developed as a response to Germanization, a policy Prussia and Austria followed when they became more aware of their "Germanness" in order to assimilate the subjected Slavic peoples and make their own societies more cohesive.
Pan-Slavism was originally about liberation of Slavs (Poles, Ukrainians, Czechs, Slovaks, Slovenes and Croats) from Austrian and Prussian rule with the help of the only Slavic great power, Russia.
The idea gained a large following among Czechs, Slovaks, Slovenes and Croats. The Croats were particularly enthusiastic about a common state for all South Slavs (Slovenes, Croats, Serbs and Bulgarians). Ukrainians showed less enthusiasm, while Poles, part of which was already living under Russian rule, showed hardly any interest at all. Serbs and Bulgarians, then still under Ottoman rule, showed very little interest for Croatian ideas, instead being more focused on a common Orthodox cause with Russia, Romania and Greece.
However, after 1848 and Russia's role as a counter-revolutionary power which crushed, among others, Slavic uprisings as well, pan-Slavism started losing its appeal to Czechs, Slovaks, Slovenes and Croats, who, while they were Slavs, were also Catholics and deeply connected with Western culture and politics. In its place a new ideology rose, Austro-Slavism, which advocated autonomy for Slavic people while remaining a part of Austria. By the end of the 19th century, Austro-Slavism almost completely replaced pan-Slavism among Czechs, Slovaks, Slovenes and Croats.
After 1878 and the independence of Serbia and Bulgaria from the Ottomans, pan-Slavic sentiments began rising in these coutries, in Serbia in particular. The old Croatian idea of a united South Slavic state started gaining currency in Serbia, and by 1914 a modification of the idea, the creation of the South Slav (Yugoslav) state, but without Bulgaria (since the Bulgarians were more than strong enough to never allow the Serbs to dominate Yugoslavia), became official Serbian policy.
So, as much as Austria had designs on Serbian territory, so did Serbia have designs on Austrian territory. This was a normal state of affairs in Europe at the time.
The idea of Yugoslavia was met with the greatest fervor among Serbs living under Austrian rule, in Croatia, Bosnia and Vojvodina. This is why most of the members of the Young Bosnia and Black Hand organizations were Serbs.
As far as I'm concerned, occupying Bosnia and Herzegovina was Austria's strategic mistake. It was an economic black hole, by far the poorest part of Austria-Hungary, and it had a Serbian majority at the time, which understandably antagonized Serbia which was bitterly opposed to such a string of events.
It should have simply handed Bosnia over to Serbia and demanded Serbian loyalty in return. As a bonus, the Croats, when facing Serbian (relative to Croatia) economic and political backwardness on their very borders, would completely lose any desire to wreck Austria to join Serbia.