0

如何在我的 html/jquery 中使用下面的 upload_response 来检查它是否正确,并相应地显示一些文本而不转到新页面?

文件上传.py 文件:

  template = loader.get_template('start_interview.html')
  context = Context({ 'upload_response': 'True'})
  return HttpResponse(template.render(context))
4

1 回答 1

0

您将需要为ajax 部分使用类似 jquery 的东西。

$.ajax({
  type: "POST",
  url: "<your url to the view that returns appropriate template>",
  data: { name: "John", location: "Boston" }
}).done(function( responseMsg ) {
  $('#notifier').html(responseMsg)
});

responseMsg是渲染的模板。完成上述操作的方法不止一种。

在您的模板中

{%if upload_response %}
 ...Your html tags or jquery if inside script block...
{%else%}
 ...Do Stuff if it is false...
{%endif%}
于 2012-10-10T19:11:21.287 回答