I struggled to find a solution to my problem. I'm not a javascript specialist, but I'm looking for a way to change the external js url depending on the onclick event to ahref.
Now I have this in my tags:
<script type="text/javascript" src="http://www.domain.com/loader.php?GID=126&go=&sid="></script>
I want the SID parameter to be set to 1 or 2 based onclick on the anchor tag. The bootloader is called using this piece of code, but the SID would need to change the right to that called by the bootloader.
<a href="/#download" onclick="javascript:Load_126(); return false;">
Is there anyone who could tell me if this is possible? And maybe point me in the right direction?
Hi,
Sedoc94
EDIT 1 : I pointed in the direction and decided that I can do it using jQuery.getScript() but still don't know how I should use it for my case.
EDIT 2 : as the script needs to be pulled out of the external domain, I will have to go with the $ .ajax () function.
Now I have:
function loadGame(sid){ $.ajax({ url: 'http://www.domain.com/loader.php?GID=126&go=&sid='+sid, dataType: "script", crossDomain: true, success: gLoad_12603() }); }
With ahref onclick, I call the loadGame function, but the console says: Uncaught ReferenceError: gLoad_12603 is not defined . It should work. But I guess it somehow gives this error, because the function exists only in the script code, which is returned from an external URL.
Any ideas how I can make it work?
Kid diamond
source share