On 13/08/2022 09.04, Dieu merci Dramani wrote:
> This work :
> productId:  1 action:  add
> cart.js:9 USER: setraco
> cart.js:20 setraco is logged in ! Sending data ...
> 
> cart.js:22
> Here is the errors that I'm trying without success:
> POST http://127.0.0.1:8000/update_Item/ <http://127.0.0.1:8000/update_Item/> 
> 403 (Forbidden)
> updateUserOrder @ cart.js:22
> (anonymous) @ cart.js:14
> 
> VM29:2 Uncaught (in promise) SyntaxError: Unexpected token '<', "
> <!DOCTYPE "... is not valid JSON
> Promise.then (async)
> updateUserOrder @ cart.js:33
> (anonymous) @ cart.js:14
> 

Most likely your updateItems functions raises and exception causing an HTTP 403 
response. The error page is then being rendered as HTML by Django which causes 
your Javascript code to fail when trying to parse it as JSON.

You should most likely be able to find the root cause of the exception in your 
log files or the output of your developer console so you known how to fix it. I 
would guess something related to access rights on your database or similar but 
the log should provide that information.

You should also consider a way of returning JSON instead of HTML when returning 
errors to the client based on the clients "Accept" header. I'm sure there's 
some generic way to do that but I haven't looked into it.

Kind regards,

Kasper Laudrup

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6AE4A623-271C-4649-80DD-A04FEF7AAD28%40stacktrace.dk.

Reply via email to