0

Hello as state I am trying to use jquery to run some php without refreshing the page, however I am new to jquery and am having trouble getting it to work, can some one please take a look.

<div id="GameBox">
    <a onclick="setscore(1);">Start</a>
</div>

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"> 
    function setscore(id) {   
        $('#GameBox').load('PHPsavemove.php?questionsCor=' + id);
    } 
</script> 

Right now I am getting the error that it does not see my function set score. I quote "ReferenceError: Can't find variable: setscore"

Please help

T Neate
  • 403
  • 2
  • 6
  • 18
  • 1
    What is the error you get? Also, you should put your code in a separate `script` block to the one which references `jquery.js` – Rory McCrossan Mar 24 '15 at 21:55
  • see edit for exact error – T Neate Mar 24 '15 at 21:59
  • As @Rory mentioned, a script block should either have content OR an `src`, not both. Because you've set `src`, the content is being ignored. Note that this is [browser-specific](http://stackoverflow.com/a/6528343/622391), and definitely not reliable! – Simon MᶜKenzie Mar 25 '15 at 00:40

1 Answers1

0

This should fix it (Place the code into a separate script tag)

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

<script type="text/javascript"> 
    function setscore(id) {   
        $('#GameBox').load('PHPsavemove.php?questionsCor=' + id);
    } 
</script> 
<div id="GameBox">
    <a onclick="setscore(1);">Start</a>
</div>
Alberto
  • 4,212
  • 5
  • 22
  • 36