Skip to content

Commit

Permalink
Fix delete
Browse files Browse the repository at this point in the history
  • Loading branch information
laffra committed Jan 3, 2024
1 parent 4f26360 commit d9d761e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ltk/jquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,13 @@ def error(jqXHR, textStatus, errorThrown):


def delete(url, handler):
wrapper = proxy(lambda data, *rest: handler(to_py(data)))
@callback
def success(data, *rest):
return handler(to_py(data))
@callback
def error(jqXHR, textStatus, errorThrown):
window.console.error("[Network] DELETE ERROR", jqXHR.status, repr(errorThrown), url)
return window.ajax(url, "DELETE", wrapper).fail(proxy(error))
return window.ltk_delete(url, success, error)


def post(url, payload, handler, kind="json"):
Expand Down
4 changes: 4 additions & 0 deletions ltk/ltk.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,8 @@
window.ltk_post = (url, payload, success, kind, error) => {
$.post(url, payload, success, kind).fail(error)
}

window.ltk_delete = (url, success, error) => {
$.ajax({ url, type: "DELETE", success}).fail(error)
}
})()

0 comments on commit d9d761e

Please sign in to comment.