Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

htmx.ajax('DELETE') #2528

Open
eimarinin opened this issue May 3, 2024 · 1 comment
Open

htmx.ajax('DELETE') #2528

eimarinin opened this issue May 3, 2024 · 1 comment

Comments

@eimarinin
Copy link

I use alpine js + htmx.

I have a button to delete selected users:

<template x-if="selected.length > 0">
             <button type="button" class="btn btn-md btn-primary-outline" 
              @click="confirm(`Удалить выбранных пользователей`) 
              && htmx.ajax('POST', '/panel/tables/users', { source: $root, target: document.body })">
              Удалить
             </button>
</template>

Using the POST method, everything is done as intended
But if I write the DELETE method, I get an error:
400 (Bad Request)

@Telroshan
Copy link
Collaborator

Hey, it sounds like a server issue there.
If you look at the Network tab of your browser's dev tools, is the request formed as expected? Is the payload identical to the POST request or do they differ? I suppose you're including other values along your request to determine which user(s) to delete, hence the question.
Is you backend actually accepting the DELETE method here? And is it properly parsing the request's data?
Do you have logs in your server to determine where that bad request error was fired from?
Feel free to share screenshots so we can better help and identify the issue btw!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants