I have a clickable map that uses js, css and xml to display. I previously was provided solutions in a previous thread How do I implement a clickable JavaScript map? using drupal_add_css() and drupal_add_js().

  1. Can I add multiple CSS files with drupal_add_css() using an array? Or, do I need to list these as separate commands?
  2. The other problem is I need to have an XML file to feed the data into the JavaScript file. I attempted to edit the JavaScript file by hardcoding the XML file location, but that doesn't seem to work.

    $.ajax({type: 'GET',url: 'sites/default/files/repfinder/xml/usaMapSettings.xml'

What should I be doing so that the JavaScript code recognizes the XML file? Without it, no map is displayed.

  • re: 1) you want to add the multiple files one by one with separate commands.
    – schnippy
    May 14 '12 at 18:05

It looks like, according to the demo page you showed, the URL is relative to the path where the JavaScript is loaded; adding a slash in front of URL passed to $.ajax() should work.

$.ajax({type: 'GET', url: '/sites/default/files/repfinder/xml/usaMapSettings.xml'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.