r/FastAPI • • Dec 30 '20

Question Fast API - AJAX Put Method not working

Good day - before any critique just wanna say I am new to FastAPI. I need help with the following...I am just trying to do a simple CRUD using bootstrap front-end.

The backend(swagger docs) is working fine....however I am not able to seemingly link front-end component. I am using Postgresql DB.

What I have done:

1- being able to Create Post method and it updates the DB successfully

2- able to get single record from DB - and display on the front-end

What is not working:

3- Update/PUT method

To do still:

4- Delete method

I am using JQuery/Ajax - which might not be the best implementation(understood and agreed) but my intent is to understand how FastAPI works both front-end and backend...

Having said above - I would appreciate if you able to have a look at the issue i logged on SO and provide some feedback please herewith the link https://stackoverflow.com/questions/65419931/fastapi-using-jquery-ajax-put-method-not-working

once working next step for me would be to find a more pydantic manner in which to make same work.

Thanks in advance

1 Upvotes

3 comments sorted by

1

u/sharpenerbottle Dec 30 '20

In the code segments you posted, your ajax calls for the edit and update button doesn't have any data provided?

0

u/barnez29 Dec 31 '20

The logic for edit button is as follows:

1- when I click on edit button - it does successfully retrieve the single data object from the database

2- on click edit button displays - the data in the update data form

3-the update button is meant to do the put request...with the data - however this keeps breaking...I get a response 200 from the server(when clicking update button)...but nothing is updated in the database

1

u/sharpenerbottle Dec 31 '20

Well when you click on the update button I don't think any data is being sent to the server, because in the code you posted in stackoverflow the Ajax call is missing data