Django Ecom Part 11 | How to make add to cart in Django using jQuery Ajax | Ajax Shopping cart

Поделиться
HTML-код
  • Опубликовано: 18 ноя 2024

Комментарии • 70

  • @akaeaa
    @akaeaa Год назад

    I love the way shark carried out,I would like to thank him.
    After going through the videos,the add to cart button would not add and the the alert message says no such product found.I have product in the database.
    I need help with it please!!

  • @waltradeekene
    @waltradeekene 2 года назад +3

    am having this error:
    Failed to load resource: the server responded with a status of 404 (Not Found).
    this is my ajax:
    $.ajax({
    method:"POST",
    url: "addtocart",
    data: {
    'prod_id':prod_id,
    'product_qty':product_qty,
    csrfmiddlewaretoken:token
    },
    success: function (response) {
    console.log(response)
    alertify.success(response.status)
    }
    });
    the error is from my ajax url

    • @arieleugenin7791
      @arieleugenin7791 Год назад +1

      ayuda

    • @arieleugenin7791
      @arieleugenin7791 Год назад

      @SharmaCoder
      HELPPPPP!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    • @arieleugenin7791
      @arieleugenin7791 Год назад

      @SharmaCoder

    • @unitra
      @unitra Год назад

      my ajax - finally work
      $.ajax({

      type: "POST",
      url: "/add-to-cart",
      data: {
      'product_id': product_id,
      'product_qty':product_qty,
      csrfmiddlewaretoken: token
      },
      success: function (response) {
      console.log(response)
      alertify.success(response.status)

      }
      });

  • @iuliandumitrache
    @iuliandumitrache Год назад +2

    Hello sharma
    When i open the Inspect and click on Add to Cart button, in the console log doesn`t apear a message. I think the button doesn't work. I watch the video 3 times and the code is the same. I think the problem is at that button class. Please help me, i need a response. Thanks a lot.

    • @chandreshsolanki7580
      @chandreshsolanki7580 Год назад +1

      Your problem solved ?please help I am also getting same error

    • @iuliandumitrache
      @iuliandumitrache Год назад

      @@chandreshsolanki7580 yes, only press in chrome CTRL+SHIFT+R to delete your cache and the code will apear

    • @archana.c2971
      @archana.c2971 10 месяцев назад

      Same issue for me when solve it??
      Please help me???

    • @SharmaCoder
      @SharmaCoder  10 месяцев назад

      Clear cache and retry.

    • @ziy4dmhd
      @ziy4dmhd 7 месяцев назад

      not working..

  • @matatahakunana8796
    @matatahakunana8796 2 года назад +2

    Hello sir how to make add to cart without user login? Thanks sir

  • @asdas-n6o
    @asdas-n6o 9 месяцев назад +1

    sir how do you fix this error failed to load resource: the server responded with a status of 500 (Internal Server Error)

    • @ziy4dmhd
      @ziy4dmhd 7 месяцев назад +1

      did you get the solution

    • @songsremixz885
      @songsremixz885 5 месяцев назад

      Bro tujhe Mila kuch solution iska same error​@@ziy4dmhd

  • @paulkaranja7670
    @paulkaranja7670 2 года назад

    I'm loving this code

  • @genoguibao759
    @genoguibao759 2 года назад +2

    jsonresponse wont display

  • @imameteraway
    @imameteraway Год назад

    i've got a 'Method Not Allowed: /add-to-cart' Error, do u know guys how to fix that?

  • @nikolat_272
    @nikolat_272 Год назад

    Hi bro , i have this error : Method Not Allowed (POST): /products/iphone-x
    Method Not Allowed: /products/iphone-x , i have used require post decorator with function based views and class based views , method post in html form , method post in js but still getting this error pls help me i really need this and is there any way that i could access to codes of this video? (just for the ajax)

    • @SharmaCoder
      @SharmaCoder  Год назад +1

      Seems like you have not added a post route for the specified url.
      Anyways, You can download the code from the description.

  • @elhusseinabdalaziz1069
    @elhusseinabdalaziz1069 2 года назад +1

    For some reason when i click the button "Add to cart" nothing happens i have no idea why, i went through the code more than 3 times and I've done everything pretty much the same

    • @SharmaCoder
      @SharmaCoder  2 года назад +1

      Check the following things:
      1. If you have given the class name correctly in the button and jqclick.
      2. Check if you have linked your custom.css to your layout file.
      3. If you have done both the above and still not working, just write and alert(); inside the jqclick function to check if your button is able to atleast reach the function on click event.

    • @elhusseinabdalaziz1069
      @elhusseinabdalaziz1069 2 года назад

      @@SharmaCoder still not working i checked the "addToCartBtn" class name i passed it correctly with the '.' selector, in the "main.html" first line is {{%load static%}}

    • @elhusseinabdalaziz1069
      @elhusseinabdalaziz1069 2 года назад

      and i wrote the function "alert()" in the success section and tried it at the beggining of the function and still not working

    • @SharmaCoder
      @SharmaCoder  2 года назад +1

      Write the alert () as the first line in the jqclick. Comment the ajax for time being.

    • @elhusseinabdalaziz1069
      @elhusseinabdalaziz1069 2 года назад

      i did that still nothing happened :(

  • @chandreshsolanki7580
    @chandreshsolanki7580 Год назад

    So sir cosole says 500(internal server error)

  • @AbhiRam-qr2yn
    @AbhiRam-qr2yn Год назад

    Bro it is not working and not showing any error. My items can't save the cart model please help

  • @ejazmohammad8563
    @ejazmohammad8563 Год назад

    After following the coding flow of adding items still i'm unable to add items to cart

    • @SharmaCoder
      @SharmaCoder  Год назад

      You are getting any errors?

    • @ejazmohammad8563
      @ejazmohammad8563 Год назад +1

      @@SharmaCoder now working, thanks !

    • @AbhiRam-qr2yn
      @AbhiRam-qr2yn Год назад

      ​@@ejazmohammad8563please help what will you do

    • @AbhiRam-qr2yn
      @AbhiRam-qr2yn Год назад

      please help i have the same problem

    • @chandreshsolanki7580
      @chandreshsolanki7580 Год назад

      ​@@ejazmohammad8563help me I am not getting any error but output is not working

  • @chandreshsolanki7580
    @chandreshsolanki7580 Год назад

    In console it is saying that 500(internal server error)

    • @SharmaCoder
      @SharmaCoder  Год назад +1

      Click on that error message. It will take you to the networks tab. There you can see the error source and rectify it.

  • @aldwinzafra1843
    @aldwinzafra1843 3 года назад

    Any updates on laravel 8 sir?

    • @aldwinzafra1843
      @aldwinzafra1843 3 года назад

      the e-commerce one

    • @SharmaCoder
      @SharmaCoder  3 года назад

      We will be continuing with the laravel ecom series after this django series..
      Will finish the Django ecom series ASAP.

  • @Kaakabaakskshd
    @Kaakabaakskshd Год назад

    I got an error int() argument must be string,a byte-like object or a number , not Nonetype

  • @chandreshsolanki7580
    @chandreshsolanki7580 Год назад

    I have everything as per video but it does not respond anything

    • @SharmaCoder
      @SharmaCoder  Год назад

      What is the issue?

    • @chandreshsolanki7580
      @chandreshsolanki7580 Год назад

      @@SharmaCoder sir when I click on button nothing happend

    • @chandreshsolanki7580
      @chandreshsolanki7580 Год назад

      @@SharmaCoder and my code is not showing any error

    • @chandreshsolanki7580
      @chandreshsolanki7580 Год назад

      ​@@SharmaCoder500(Internal server error)

    • @SharmaCoder
      @SharmaCoder  Год назад

      Click on that 500 error message in your console. It will take you to the networks tab. There you can see the error source and rectify it.

  • @anvithamadala4510
    @anvithamadala4510 Год назад

    I am getting post 500 internal server error

    • @kpsanjna
      @kpsanjna Год назад

      how did u resolve?

    • @chandreshsolanki7580
      @chandreshsolanki7580 Год назад

      ​@@kpsanjnaI am also getting same error pls help if you get solution

    • @kpsanjna
      @kpsanjna Год назад

      Fst check the code in detail, then close your db and your project and then connect again.. It will surely work.

    • @chandreshsolanki7580
      @chandreshsolanki7580 Год назад

      @@kpsanjna it works

    • @chandreshsolanki7580
      @chandreshsolanki7580 Год назад

      @@kpsanjna thank you

  • @kels7980
    @kels7980 2 года назад

    Uncaught TypeError: $.ajax is not a function

    • @ziy4dmhd
      @ziy4dmhd 7 месяцев назад

      check the script tag , ajax link tag etc in head section etc.

    • @zeelpatel9373
      @zeelpatel9373 6 месяцев назад

      @@ziy4dmhd same problem Uncaught TypeError: $.ajax is not a function