Search code examples
jqueryruby-on-railsjqxhr

jqXHR vs. jQuery AJAX-requests in Rails


I don't understand why this jQuery.AJAX-request to a .csv-file fails to display a Highchart chart in Rails:

var jQuery = $.get('foo.csv', function(data) {}

whereas this one displays just fine:

var jqxhr = $.get('foo.csv', function(data) {}

Can anybody please explain?


Solution

  • jQuery is the name of the main function in the jQuery library ($ is just a synonym for it). You shouldn't reuse it in your own code. Although if this is a local variable, I don't think it should affect the library, it uses the global variable window.jQuery. But it's still a bad idea to use this variable name, it will be confusing.