0

以下のhtml/jqueryでupload_responseを使用して、それがtrueかどうかを確認し、新しいページに移動せずにそれに応じてテキストを表示するにはどうすればよいですか?

fileupload.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 に答える