title: AJAX Call to python function not happening from JavaScript function in Django
body: <p>This is a full flow which has to be taken care here. I am coding in Django/Python/Web Development.</p>
  
  <p>I have an html page which has got a dummy button which is triggering all the functions that I want to perform now. Instead of the dummy button I want an uploadFunction() to perform the same actions. I googled and found that the best way to do this was by using AJAX, since the action to be performed requires to hit the server.</p>
  
  <p>This is my uploadFunction() in jsfunctions.js file</p>
  
  <pre><code>    function upload() {
     //does some upload      
      alert('before dummy')
      ajaxCallFunction();
  }
  </code></pre>
  
  <p>I am giving a call to a ajaxCallFunction() which I have in another separate file ajax.js. The ajaxCallFunction() is as follows:</p>
  
  <pre><code> $(document).ready(function(){
     function ajaxCallFunction(){
      alert('right before ajax call')
       $.ajax({
          type: "POST",
          url: "/dummy/{{ frame.slug }}/",
          alert('AJAX CALL');
          data: {
          'snapshot' : $('#snapshot').val(),
          },
          success: dummy,
          dataType: 'html'
          alert('just finished')
          }
          headers:{
              'X-CSRFToken':csrftoken
          }
      });
  }
  });    
  
  function dummySuccess(data, textStatus, jqXHR)
  {
      $('#dummySuccess').html(data)
  }
  </code></pre>
  
  <p>I want my the upload() to call the ajaxCallFunction() and redirect it to a method in views.py (which I have mapped in my urls.py). However, my code does not hit the ajaxCallFunction at all.(I cant see the alerts that I have put in the ajaxCallFunction).  In my calling page I have all of these included.</p>
  
  <pre><code>&lt;script language="javascript" type="text/css"&gt; &lt;/script&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;        
  &lt;script language="javascript" src ="/static/js/jsfunctions.js"&gt;&lt;/script&gt;
  &lt;script language="javascript" src ="/static/js/ajax.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>I have the the function which gets the <code>CSRF Token</code> too (since this is a post method) in my ajax.js. Am I missing something here? What else do I need to do to make this ajax call? Please help. Thanks in advance :)</p>