6👍
Firstly, you don’t need to escape the dot if you want it to mean any symbol (in urls.py
).
url(r'^show/(?P<url>.+)$', 'myapp.views.json_process')
Secondly, use encodeURIComponent
to properly escape the parameter.
var url = 'http://127.0.0.1:8000/show/' +
encodeURIComponent('http://www.google.com')
By the way, don’t use mixedCase for function names in Python:
Function names should be lowercase, with words separated by
underscores as necessary to improve readability.
Another note that might help in future: don’t hardcode Django URLs in JavaScript. You can generate them dynamically either in your views:
from django.core.urlresolvers import reverse
url = reverse(
'myapp.views.json_process',
kwargs={'url': 'http://www.google.com'}
)
Or in templates:
{% url myapp.views.json_process url="http://www.google.com" %}
Source:stackexchange.com