【发布时间】:2018-03-02 07:07:18
【问题描述】:
这是第一页,在那里我可以使用ajax请求url,并将请求数据传递给它。
我的ajax代码如下:
$.ajax({
type:'post',
url:'/app_api/server_payment/',
contentType:'application/json',
data:JSON.stringify({'params':buy_data}),
dataType:'json',
success:success_func
})
function success_func(response){
console.log(response)
}
在views.py中:
def server_payment(request):
if request.method == 'POST':
is_login = request.session['is_login']
if is_login:
print ('server_payment_2 ', is_login) # it prints
return render(request, 'app_admin/payment.html')
else:
return render(request, 'frontend/login.html')
在 views.py 中,我想渲染 payment.html 并跳到它。
这是我的 payment.html。
但是server.html页面没有跳转到payment.html,不知道怎么实现。
我尝试使用self.location=/app_api/server_payment/,但我无法使用 post 方法传递数据。
第一个快照中有一些详细信息。
【问题讨论】: