Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always 403 forbiden for json package,@csrf_exempt do not wrok #46

Open
thinksource opened this issue Jul 7, 2013 · 0 comments
Open

Comments

@thinksource
Copy link

Hi, I want to send an ajax request: by $.post
javascript code:
data='{"jsonrpc": "2.0", "method": "secret", "params": {"a": "as12"}, "id": 1}'
$.post(
'RPC2',
data,
function(data1) {
alert("Response: " + data1);
}
);

the python receive code:
@csrf_exempt
@jsonrpc_method('app.addStrings(arg1=String) -> String', validate=True)
def add(request, secret_data):

print request.COOKIES
print request.body
re=request.REQUEST
print repr(re)

result=0;
for k in re:
    print "dict[%s] =" % k,re[k]
rep = re.get('params', None)
print rep
return HttpResponse(json.dumps({'message':'Hello World'}), content_type="application/json")

but I get the 403 Forbiden as CSRF problem.
I think I have already writen @csrf_exempt, but it don't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant