Grab Script

We include our ‘core’ library, in the header


    <script src="../Include/Core.js" type="text/javascript"></script>
          

The target of the link is a chunk of JavaScript in an .asp file, this is added to the <head> of the document, where it gets run as soon as the response is received from the server.

When the page loads, it loops through all a elements and attaches the function getPlayersFromServer to each one.

The function getPlayersFromServer calls ssGrabScript(el.href); when any of these are clicked.


    function getPlayersFromServer(e)
    {
      var el = ssExtractEl(e);
            ssGrabScript(el.href);
      return ssStopTheRest(e);
    }
          

ssGrabScript() fetches an .asp page which loops through all players for the team and simply returns a string.


    alert("Players: Nedum Onuoha, Pablo Zabaleta, Stephen Ireland, Shaun Wright-Phillips, Valeri Bojinov, Robinho, Elano, ");
          

This is inserted into a <script> element in the head of the document by ssGrabScript() causing the script to be run.

This is used to get chunks of JavaScript from the server (and run them) in the same way that ssGrabFile() gets chunks of HTML from the server (and inserts them). It is especially useful for referencing a database, and using JavaScript APIs such as Google Maps.

Exclamation Warning

  • As the script is included in the head of the document, you need to use the use Firebug’s HTML tab to view the response given by the target page.