title: How to use render_to_response to render a html page within div in Django?
body: <p>I have a view which returns data to template using render_to_response function as below -</p>
  
  <pre><code>@page_template("app/jsComp.html") # just add this decorator
  def jsComp(request, template="app/jsComp.html", extra_context=None):
      basic_v_obj = js_basicinfo.objects.get(cid = request.session.get('id'))
      # Sends json data objects in context container
      .....
      context = {
      'cars': basic_v_obj,
      'companies':wc_v_obj,
      }
      context['wc_V_json'] = mark_safe(json.dumps(wc_v_json_list, ensure_ascii=False))
      return render_to_response(template, context, context_instance=RequestContext(request)) 
  </code></pre>
  
  <p>Am able to view the context data in my template (jsComp.html) using below notation</p>
  
  <pre><code>  // Global variable jdata
      {% if wc_V_json %}
      jdata = {{ wc_V_json|safe }};       
      {% endif %}
      alert('Sk: '+JSON.stringify(jdata));
  </code></pre>
  
  <p>I wanted to use this template itself inside a div in another template say index.html
  Also, I would like to send id from index.html via angularjs ajax call.
  so, my view should consider cid equals the value that I pass via angularjs.</p>
  
  <p>My question is how can I do it in index.html ?</p>
  
  <pre><code>$scope.preview_ang = function (clicked_id) {
          $http({
              method: 'POST',
              url: 'pvcan',
              data: {
                  'id': clicked_id
              },
              headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
              })
             .success(function (data) {
               if (data == "null") {
                   alert('server returned nothing but success');
               } else {
                   /// WHAT SHOULD I WRITE HERE SUCH THAT I CAN RENDER jsComp.html IN A DIV IN THE INDEX.HTML
                 }
             })
             .error(function (data, status, headers, config) {
                        alert('server returned error :'+status);
             })
      }
  </code></pre>
  
  <p>What should I write in the success function of my angularjs ajax call to render jsComp.html in a div with some id in the index.html ?? Could you please help me with the approach ?</p>
  
  <p>Am aware that I can use something like this, but this is not working (Tried calling load_page in success function but no use. How can I achieve this requirement?</p>
  
  <pre><code>        function load_page(){
              document.getElementById("info").innerHTML='&lt;object type="text/html" data="previewcan" style="width:100%;height:100%;"&gt;&lt;/object&gt;';
          }
  </code></pre>
  
  <p>Tried the below in the view but it doesn't work - (Request, Response)</p>
  
  <pre><code>@page_template("app/jsComp.html") # just add this decorator
  def jsComp(request, template="app/jsComp.html", extra_context=None):
      data=json.loads(request.body.decode())
      v_cid=data["id"]
      basic_v_obj = js_basicinfo.objects.get(cid = v_cid)
      # Sends json data objects in context container
      .....
      context = {
      'cars': basic_v_obj,
      'companies':wc_v_obj,
      }
      context['wc_V_json'] = mark_safe(json.dumps(wc_v_json_list, ensure_ascii=False))
      return HttpResponse(context, context_instance=RequestContext(request))
  </code></pre>