Can AJAX load variables for a Javascript Function?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Han
    New Member
    • Sep 2010
    • 2

    #1

    Can AJAX load variables for a Javascript Function?

    I've used AJAX a little, but am wondering whether it can be used for this:
    A Javascript function which draws a shape using the HTML5 canvas tool, but which gets the coordinates of the shape from an external document using AJAX.

    Basically, can AJAX be used to dynamically import variables which can then be used by the rest of the Javascript code?

    Thanks.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    Try to transfer data using XML. Ajax can load the xml data and then using xml parsing you can parse and assign to proper variable.

    Comment

    • Terry Han
      New Member
      • Sep 2010
      • 2

      #3
      That's interesting. I've never done much with XML, but I'll look into it. Many thanks.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        while XML would be an option it is often more to prefer to use a JSON-string to avoid the XML-parsing-overhead and in most cases even the bigger payload of the response. a JSON-structure could simply be evaluated to JavaScript ...

        Comment

        Working...