javascript - Ajax Django Empty List -
I have been stuck with this problem for a few days and there is a problem finding a solution. I have taken a look at Google and a lot of similar questions here, but cant seems to get this work done. The closest I have come to me is that I have now.
Actually what I'm trying to do, when a user clicks on checkout, a JavaScript prompt opens and asks to check the item, then another directly, check Asking for the name of the authorized person.
& lt; Script & gt; $ (Document) .ready (function () {$ ( 'chkrclass1.') Function (event Click () {var authby; var cause; var chkr = $ ( 'tdata :. Eq (3)' ..) HTML (); if (chkr == "out of stock") {;) EventkpreventDefault (; alert ( "this item went already checked out!")} if (confirm ( "are you sure Want to keep this item checkedout? ") == true) {cause = sign (" Please enter your reason for picking item "); authby = sign (" Please enter who authorized checkout. "); $ Agend ({url: '/ book / checkout /', type: 'post', d Ta: {"id": authby, "ids": reason} Traditional: true, success: work (data) {warning ('checkout success!'); // $ ("body") .append (data);} }) If (cause == '') {Warning ("you have never entered a reason ... canceling checkout ..."); event.preventDefault ();} if (authby == '' ) {Warning ("You have not authorized checkout, canceled checkout ..."); event.preventDefault ();}} and {event.preventDefault ();}});}); & Lt; / Script & gt; I know that the code is very easy and can be customized in many ways, but I am still learning and hopefully we will find it soon.
In this view
def bookcheckout (request): chkoutcons = {} bchkoutcons [ 'ogphead'] = "OGPSS list database" bchkoutcons [ 'title'] = "Checkout Success" bchkoutcons ['thedate'] = Datetime.datetime.now () strftime ( '% D% m-% Y') username = request.user.username username = username.capitalize () if username.endswith ( 'ogpss'): username = user name [: -5] bchkoutcons [ 'username'] = username auths = request.POST.getlist ( 'ID [0]') causes = request.POST.getlist ( 'IDSs [0]') bookch = BookCheckout ( bookcheckoutdate = datetime. datetime.today (), bookcheckoutby = request.user.username, bookauthby = auths, bookreason = reasons, bookid = bookitem) bookch.save () return render_to_response ( 'checkoutsuccess.html', bchkoutcons, context_instance = RequestContext ( Request)) When I go to the admin section and I know the information from CP, I'm just an empty list, values are
I have also tried
request.POST ("id") But the query is not worth the date as I said, there is still a lot to learn.
Can someone help me with doing wrong?
The post is a dictionary
Requests. POST ["ID"]
Comments
Post a Comment