Reputation: 4275
Using Dajaxice I want to pass a parameter to a python function.
In the html file I have the following statement
<a href="#" onclick="Dajaxice.myapp.sayhello(Dajax.process,{'dir':3} )"> <i class="icon"></i></a>
and in my ajax.ps file I have the function
@dajaxice_register
def sayhello(request, dir):
print(dir)
It works fine if I remove the second argument dir in both the html and the python file, but with having dir, I get the error message "Something goes wrong".
Does anybody know what could be the issue here?
Upvotes: 3
Views: 899
Reputation: 1
change the sayhello to :
def sayhello(request):
my_dict=json.loads(request.POST['argv'])
dir=my_dict['dir']
print(dir)
Upvotes: 0
Reputation: 2339
if you use Python 3.*, then in module dajaxIce make the changes file venv/lib/python3.2/site-packages/dajaxice/views.py
def safe_dict(d):
"""
Recursively clone json structure with UTF-8 dictionary keys
http://www.gossamer-threads.com/lists/python/bugs/684379
"""
if isinstance(d, dict):
return dict([(k, safe_dict(v)) for k, v in d.items()])
elif isinstance(d, list):
return [safe_dict(x) for x in d]
else:
return d
Upvotes: 1