title: wordpress ajaxurl to fetch backbone model
body: <p>I'm learning Backbone.js and trying to build simple theme based on it. I have in functions.php this code to load js:</p>
  
  <pre><code>    function load_js() {
        wp_enqueue_script('app-js', get_template_directory_uri() . '/app.js', array('backbone'));
        wp_localize_script('app-js', 'mechanics', array('ajaxurl' =&gt; admin_url('admin-ajax.php')));
      }
  
      add_action('wp_enqueue_scripts', 'load_js');
  </code></pre>
  
  <p>And in app.js this simple code to fetch posts:</p>
  
  <pre><code>(function($){
      var Post = Backbone.Model.extend({});
  
      var Posts = Backbone.Collection.extend({
              model: Post,
              url: mechanics.ajaxurl
      });
  
      var new_posts = new Posts;
      new_posts.fetch();
  })
  </code></pre>
  
  <p>Server side works (I've tested it with jquery). If think problem is with url statement. Can someone tell me how it should look or if there is a difference between jQuery ajax and Backbone sync url?</p>
  
  <p>Working jQuery version</p>
  
  <pre><code>jQuery(document).ready(function() {
      var $ = jQuery;
  
      $.ajax({
      type: "GET",
      url: mechanics.ajaxurl,
      data: { action : 'mechanics_get_posts' },
      dataType: "json",
      success: function( response ) {
          alert( response );
          }
      });
  });
  </code></pre>