Django/Ajax Get "data" returning html from firing page instead of target view
<p>I'm using the following simple AJAX call.</p>

<pre><code>$.ajax({
    url: $('#currentNodes').attr('target'),
    type: 'get',
    dataType: "html",
    success: function(data) {
        console.log(data);
    },
    failure: function(data) { 
        alert('error');
    }
}); 
</code></pre>

<p>It is supposed to grab the target from the following element:</p>

<pre><code>&lt;p&gt;&lt;a href="{% url "current_nodes" view.slug %}" id="currentNodes"&gt;Test&lt;/a&gt;&lt;/p&gt;
</code></pre>

<p>When I click on the above element, my browser displays the HTML I set up in my <strong>views.py</strong>:</p>

<pre><code>def current_nodes(request, slug):
    html = "&lt;html&gt;&lt;body&gt;Smoke Test for {}&lt;/body&gt;&lt;/html&gt;".format(slug)
    return HttpResponse(html)
</code></pre>

<p>at the url defined in my <strong>urls.py</strong></p>

<pre><code>url(r'^(?P&lt;slug&gt;[a-zA-Z0-9-]+)/current_nodes/$', current_nodes, name="current_nodes"),
</code></pre>

<p>But according to <code>console.log</code>, the Ajax call from this link receives the response that comes from the view that is serving the current page, not the one that I ask for in the target. Sure enough, if I try to do anything with it, it displays the full html of the template I am on, rather than plugging in the html I'm trying to process.</p>

<p>What am I missing?</p>