我写了一个响应来自浏览器的ajax请求的视图。它是这样写的 -如何在没有模板的情况下在Django中发送空响应
@login_required
def no_response(request):
params = request.has_key("params")
if params:
# do processing
var = RequestContext(request, {vars})
return render_to_response('some_template.html', var)
else: #some error
# I want to send an empty string so that the
# client-side javascript can display some error string.
return render_to_response("") #this throws an error without a template.
我该怎么做?
这里是我如何处理在客户端服务器的响应 -
$.ajax
({
type : "GET",
url : url_sr,
dataType : "html",
cache : false,
success : function(response)
{
if(response)
$("#resp").html(response);
else
$("#resp").html("<div id='no'>No data</div>");
}
});
爽哦!简单,所以我的问题原来是非常基本的!无论如何感谢您的帮助。今天学到了新东西。 – 2010-11-08 11:15:07