Try not to create urls in javascript, when rendering the html use rails helper to create data-url attribute.