For WebGL I was trying to work with asset bundles, but im not able to download the asset bundle in WebGL

I created the asset bundles with the following code:

BuildPipeline.BuildAssetBundles ("AssetBundles",BuildAssetBundleOptions.CollectDependencies,BuildTarget.WebGL);

I compiled to webGl and put all my bundle assets in the same folder as the index file and release folder.
Then i started up a local server in that folder and loaded the project on localhost.(using python)
The bundle URL i pointed to is: http://localhost:5050/cube.unity3d so that the bundle can be found.

But when i try to load the assets and instantiate the item i get the following error:

The item you are trying to instantiate is null.

I am downloading the asset using the below code:

IEnumerator DownloadAssetBundle() {
		Debug.Log("Downloading the asset bundle");
		using (WWW www = new WWW(BundleURL)) {
		yield return www;

			if (www.error != null)
				throw new Exception("WWW download had an error:" + www.error);
			AssetBundle bundle = www.assetBundle;
			if (AssetName == ""){
			Instantiate(bundle.mainAsset);
				Debug.Log("No Name for asset");
			}
			else{
				Instantiate(bundle.mainAsset);
				Debug.Log("Download Completed");
			}
		} 
	}

But Web Player was able to load the asset.
Im not sure what the issue is with WebGL…?
Can you please point me in the right direction?
Note:Im using Unity 5.1.1f1

@GameDevBryant Thank you for the reply. Yes it was due to wrong asset bundle target platform. I set it WebGL and it worked.

@ravikiran2091 Double check to see what the BuildTarget is for your asset bundles. Bundles are platform-specific. WebPlayer bundles don’t work in WebGL. Hope that helps.