Hi, I'm new to Django. I'm creating a game that has a 10x10 board and when
a cell is clicked upon, it will be marked with an "X". Marking the cells
works in jquery but I want to send data to server side to let it know that
the cell is marked. That way when I quit the game and come back later, it
will have an "X" on that cell. Currenly, my jquery code is this:
$('.target_cell').click(function(){
if ($(this).text() != "X" && $(this).text() != "H"){
$(this).text("X");
var spot = $(this).attr('name'); //Cell index number like
in an array but in string format
$.ajax({
type: "POST",
url: "/target_spot/{{game.id}}/" + spot + "/",
data: spot
});
}
And my view code is this:
@csrf_exempt
def target_spot(request, game_id, spot):
if request.is_ajax():
game = fetch_game(request.user, game_id)
game.creator_target_board[int(spot)] = "X"
game.save()
>From my server log, i get the following message when I click on a cell:
"POST /target_spot/1/0/ HTTP/1.1" 500. Any ideas on how to solve this?
Thanks!
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/Aux0I4-eUNMJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.