If that's an AJAX POST request, then it may be because you are not passing
the CSRF token in the header. Add this code before doing the AJAX call:

function csrfSafeMethod(method) {
    // these HTTP methods do not require CSRF protection
    return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));}$.ajaxSetup({
    crossDomain: false, // obviates need for sameOrigin test
    beforeSend: function(xhr, settings) {
        if (!csrfSafeMethod(settings.type)) {
            xhr.setRequestHeader("X-CSRFToken", csrftoken);
        }
    }});

See here: https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax




On Fri, Jul 5, 2013 at 10:03 AM, <nesor...@ymail.com> wrote:

> So I have django 1.5.1 installed,
> have persistent messages installed, and have messages displaying in a list
> via the template reference {% include
> "persistent_messages/message/includes/messages.jquery.html" %}
>
> The following javascript click trigger is bound to an anchor tag within
> the list:
>
> $(closeSelector).click(function(event) {
>         event.preventDefault();
>         $.ajax({
>                 url: "//url.com/"+$(this).attr('href')
>         })
>         if ($(messageSelector).length <= 2) {
>             $(closeAllSelector).messageClose();
>         }
>
>         $(this).closest(messageSelector).messageClose();
>     });
>
> The link being referenced is https://url.com/messages/mark_read/583/
> If I access that same link manually in the address bar, the appropriate
> call in the backend
> gets executed and the message is marked read. The ajax equivalent never
> seems to respond.
> I added logging to the persistent messages view and confirmed the ajax
> call is never
> calling mark_read() method.
>
> Chrome dev tools indicates that the ajax call is "pending" and never
> changes from this state.
>
> Any suggestions or ideas on what may be causing this?
>
> NOTE: I prepend the "//url.com" to avoid getting 'insecure content'
> warnings, since this ajax code is being executed
> from a https page. This change did not seem to affect the bug in any way,
> since the response is the same.
>
> Thanks in advance
>
> --
> 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