If I correctly understand you are using jQuery.ajax(). Documentation says
"Data to be sent to the server. It is converted to a query string, if not
already a string. It's appended to the url for GET-requests." So I think
that the ajax() function is calling the URL "/pi/?pathID=somevalue". May
you perhaps check the devel server output?

Leonardo Giordani
Author of The Digital Cat <http://lgiordani.github.com>
My profile on About.me <http://about.me/leonardo.giordani> - My GitHub
page<https://github.com/lgiordani>- My Coderwall
profile <https://coderwall.com/lgiordani>


2013/9/18 <7equivale...@gmail.com>

> I have a javascript file that successfully request a Django view. However
> it seems as if it is not passing the key:value pairs. I have created an if
> else statement that test for the key, and it never see's it. Not sure how
> to proceed. Here is my django View and Javascript click function, in the
> view the else statement always executes
>
> def pi_page(request):
>
>   if request.method == "GET":
>     get = request.GET.copy()
>     if get.has_key('pathID'):
>         path_ID = get['pathID']
>         path = Path.objects.get(pathID=1)
>        #path.pathFill = '#fff'
>         path.save()
>         variables = RequestContext(request, {'path': path})
>         return render_to_response('main_page.html',
> RequestContext(request))
>     else:
>         path = Path.objects.get(pathID=2)
>         path.pathFill = '#eee'
>         path.save()
>         variables = RequestContext(request, {'path': path})
>         return render_to_response('main_page.html',
> RequestContext(request))
>
>
> .click(function(){
>                         var outputColor =
> document.getElementById("output");
>                         var outputColorFill =  outputColor.value;
>                         var pathID = paths[arr[this.id]].pathID;
>                         var data = { pathID:pathID };
>                         $.ajax({
>                             url:"/pi/",
>                             cache: "false",
>                             data:data
>                         });
>
>                     })
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to