title: How to fetch json response from another url in django?
body: <p>I have created 2 views in django namely</p>
  
  <pre><code>   def next_qn_url(request):
          test_result1 = 'questionansewrchoice'
           return JsonResponse({'test_result':test_result1})
      def last_qn_url(request):
           test_result2 = 'questionansewrchoice'
           return JsonResponse({'test_result':test_result2})
     def test(request):
           test = 'testchoice'
           return render(request, 'ap/test.html', {})
  </code></pre>
  
  <p>i have also registered these views in urls.py</p>
  
  <pre><code>urlpatterns = [
      url(r'^test/$', views.test, name='test'),
      url(r'^next_qn_url/$', views.test, name='next_qn_url'),
      url(r'^last_qn_url/$', views.test, name='last_qn_url'),
      url(r'.*', views.home, name='home'),    
  ]
  </code></pre>
  
  <p>I send data from my test page to the other 2 views and try to fetch their json response and update my test page with the help of jquery getJSON function.</p>
  
  <pre><code>   $.getJSON('/next_qn_url/', selected_qn_ans, function(data) {
  
             console.log(data);
  
                  });
  
  $.getJSON('/last_qn_url/', selected_qn_ans, function(data) {
  
             console.log(data);
  
                  });
  </code></pre>
  
  <p>I am just giving a rough draft here. But in the jsonresponse, i get the whole test page again and again with all html but not json. Is it not correct way to do it or guide me through this process. Thanks</p>