Created
April 6, 2015 20:32
-
-
Save dhbradshaw/237e82bba3290e8217a9 to your computer and use it in GitHub Desktop.
django ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// uses jquery | |
$.ajax({ | |
type: "POST", | |
url: "{% url 'attachment-object-coupling' project.slug %}", | |
data: { | |
attachment: attachments.attr("id"), // attachment instance_id | |
object: objects.attr("id"), // object instance_id | |
csrfmiddlewaretoken: '{{ csrf_token }}' // if not configured to include token in every post | |
}, | |
success: function(data) { | |
updateDOM(data); // define elsewhere | |
}, | |
error: function(jqXHR, textStatus, errorThrown) { | |
alert("Error, status = " + textStatus + ", " + | |
"error thrown: " + errorThrown | |
); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment