If you're using jQuery 1.5.1 or above you can do this instead
// using jQuery
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
Oh I see. Meanwhile I'm trying to implement the token but I cant get this
to work, I copied the code from Django's docs and now Im getting a
javascript error syaing that the function sameOrigin is not defined.
*Code*function getCookie(name) {
var cookieValue = null;
if (do
In most cases, including the CSRF token in AJAX requests is trivial, and
processing the token is handled automatically by Django. I would recommend
spending a few minutes to implement the CSRF protection in your code of you
plan to ever move to production. It is easy enough and pays good dividends
Is is required by default.
I would recommend including the csrf token in your ajax request. If you
still want to prevent the CSRF verification in your view then you can use
the "csrf_exempt" decorator
https://docs.djangoproject.com/en/1.7/ref/contrib/csrf/#utilities
On Fri, Feb 20, 2015 at 9:05
According to Django documentation I can include a crsf token to prevent
malicious acts, but it is not necessary right? Or am I getting this wrong?
Because right now I wouldn't mind skipping the crsf token step for a little
while I manage to get the rest of the essential things to work.
sexta-fe
There's no "range" in django templates, you just use
{% for elem in sols %}
Regarding making the request using POST, are you sure you're not having a
proble with CSRF?
https://docs.djangoproject.com/en/1.7/ref/contrib/csrf/
It has a section for AJAX requests
On Thu, Feb 19, 2015 at 7:44 PM,
Thank You guys for all the aswers. Your were crucial debugging this error.
By the way, on the GET request matter, I'm using a GET because I can't
actually get POST to work I'll explain: As I execute the POST request, the
url is loaded and everything runs fine except that the code on the view
d
Thank you all for being so fast aswering! I've looking through your answers
and I've improved my code altough, I'm stuck with another error right now,
wich is:
Environment:
Request Method: GET
Request URL:
http://localhost:8000/saveToDbAndReturn/?sols=%5B%5B%5B%2211C%22,%2211E%22,%229E%22,%
What is being sent to the view from the browser is fine, it's just being
url encoded, the actual value is something like this then:
[[['5E', '10A', '8D'], ['8B', '11B', '12G'], ['8C', '7B'], ['12C', '11F',
'6A'],['5E', '10G', '10H'],['8A','11E'], ['7A', '12E', '12F'], ['5A',
'11C', '12B','11G'], [
You may need to use | safe filter in your tag since your output is being
encoded.
E.g.
{{output|safe}}
Cheers,
M
On 19 February 2015 at 07:37, João Marques
wrote:
> This is what is being sent to the view:
>
>
> %5B%5B%5B%275E%27,%20%2710A%27,%20%278D%27%5D,%20%5B%278B%27,%20%2711B%27,%20%271
Hi,
may be that this example(s) help:
https://godjango.com/blog/working-with-json-and-django/
good luck
2015-02-18 21:37 GMT+01:00 João Marques :
> This is what is being sent to the view:
>
> %5B%5B%5B%275E%27,%20%2710A%27,%20%278D%27%5D,%20%5B%278B%27,%20%2711B%27,%20%2712G%27%5D,%20%5B%278C%27
This is what is being sent to the view:
%5B%5B%5B%275E%27,%20%2710A%27,%20%278D%27%5D,%20%5B%278B%27,%20%2711B%27,%20%2712G%27%5D,%20%5B%278C%27,%20%277B%27%5D,%20%5B%2712C%27,%20%2711F%27,%20%276A%27%5D,%5B%275E%27,%20%2710G%27,%20%2710H%27%5D,%5B%278A%27,%2711E%27%5D,%20%5B%277A%27,%20%2712E%27,
Thank you so much for all the answers so far. I must say that I totally
failed not checking the method that both of you guys presented (just
acessing the GET url on the browser).
I actually gives me an *error*:
ValueError(errmsg("Expecting value", s, err.value)) from None
I've searched and it
On Wed, Feb 18, 2015 at 1:27 PM, João Marques wrote:
> Hey guys, so basicly I want to send a GET request with ajax to one of my
> views and the specific view returns an html response that will be loaded on
> a div.
> The problem is that is doesn't seems to work at all. Nothing happers on the
> div
When you access the AJAX resource directly from your browser (
http://127.0.0.1:8000//saveToDbAndReturn?sols=) are you also
getting a blank page?
Also try putting a print statement or debugging poing (using pdb) at the
beginning of the controller and check if it is actually being called.
Im getting nothing really... I just do alert(response); and nothing shows
up.
quarta-feira, 18 de Fevereiro de 2015 às 14:48:48 UTC, Vijay Khemlani
escreveu:
>
> What is the actual content of the response you are getting from the AJAX
> request?
>
> On Wed, Feb 18, 2015 at 10:27 AM, João Marque
What is the actual content of the response you are getting from the AJAX
request?
On Wed, Feb 18, 2015 at 10:27 AM, João Marques
wrote:
> Hey guys, so basicly I want to send a GET request with ajax to one of my
> views and the specific view returns an html response that will be loaded on
> a div
Hey guys, so basicly I want to send a GET request with ajax to one of my
views and the specific view returns an html response that will be loaded on
a div.
The problem is that is doesn't seems to work at all. Nothing happers on the
div.
Please help me community! Thank you!
*HTML to be filled
18 matches
Mail list logo