weixin_33693070 2016-05-03 11:25 采纳率: 0%
浏览 68

ajax django结果显示

I'm using following ajax code:

  $.ajax({
    type: "POST",
    url: "/home/ajax/graph/"+ atr,
    dataType: "html",
    data:{
      group_id : '{{groupid}}',
      csrfmiddlewaretoken: '{{ csrf_token }}',
      node_id : atr 
    },
    success: function(result) {
         $("#info").html(result);
    },
    complete: function(){   }
  });

the url and view are working properly. The data goes till the last template by the help of redirection from view file.

view code :

def adminRenderConceptGraph(request,group_id,node_id=None):
  if request.is_ajax() and request.method == "POST":
    group_name = u'home'
    if node_id:
    req_node = node_collection.one({'_id':ObjectId(node_id)})
    template = 'ndf/graph_concept.html'
    variable = RequestContext(request, {'node':req_node })
    return render_to_response(template,variable) 

its corresponding url is:url(r'^graph/(?P<node_id>[^/]+)$', 'adminRenderConceptGraph', name='adminRenderConceptGraph'),

It's suppose to display a graph in the overlay. The data reaches the graph template in the overlay and this is the warning shown in the console. The screen just freezes.

Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

  • 写回答

1条回答 默认 最新

  • weixin_33688840 2016-05-03 12:00
    关注

    This could happen it you have a <script src="/somescript.js"></script> tag in yout template, that you are returning via AJAX (that is template ndf/graph_concept.html). More info at related question https://stackoverflow.com/a/28478146/3906845

    评论

报告相同问题?