pickab00

pickab00

Member Since 1 Year Ago

Experience Points 7,870
Experience Level 2

2,130 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 2
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • Start Your Engines Achievement

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • First Thousand Achievement

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • One Year Member Achievement

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • Two Year Member Achievement

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • Three Year Member Achievement

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • Four Year Member Achievement

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • Five Year Member Achievement

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • School In Session Achievement

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • Welcome To The Community Achievement

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • Full Time Learner Achievement

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • Pay It Forward Achievement

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • Subscriber Achievement

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • Lifer Achievement

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • Laracasts Evangelist Achievement

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • Chatty Cathy Achievement

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • Laracasts Veteran Achievement

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • Ten Thousand Strong Achievement

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • Laracasts Master Achievement

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • Laracasts Tutor Achievement

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • Laracasts Sensei Achievement

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • Top 50 Achievement

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

16 Jan
1 month ago

pickab00 left a reply on How To Count In Jquery Each Function

@JOSEFELIPETTO - Ok it took me a while to understand what you are saying. So basically once i select something it creates an object. And it updates that object when I select other items. So how can I count this as it is is my question. I do not want to go through the coding and change it all over again.

pickab00 left a reply on How To Count In Jquery Each Function

@JOSEFELIPETTO - Yes that I do get. But why am I getting an empty object when I select alcoholic? And how can I keep this as it is and just count the shopping cart items. Because when I push all to the shopping cart, it does show up on shopping cart but not when I console log

pickab00 left a reply on How To Count In Jquery Each Function

@VILFAGO - https://ufile.io/3bljx

That is the file. Don't mind some of the comments. It is a combo of node/spring so there are some deps. But that would not be required as that is not needed for jquery/js

pickab00 left a reply on How To Count In Jquery Each Function

@VILFAGO - Can I post the whole file here? It would be really hard to give codes piece by piece

pickab00 left a reply on How To Count In Jquery Each Function

@JOSEFELIPETTO - For better understanding here is a video attached,

https://vimeo.com/user93974771/review/311713711/f39ca51fa1

Please don't mind the console errors. As shown in the video, when I purchase 2 items it shows up as two. And when I add alcohol from the alcohol section, it is not added to that. But If I do a refresh and add just alcohol, it comes as blank object but the data is still inside it. I do not know what is going on. I can add other things (some of them atleast) to the shopping cart and have it inside of the shopItemId_23. But as shown, some other items from other categories and Alcohol does not add. They are blank objects if I add only them to shopping cart after a refresh.

pickab00 left a reply on How To Count In Jquery Each Function

@JOSEFELIPETTO - Referencing to the last answer. This is what I am getting as a result for the ones which are not console logging from the basket. When I console.log(shopingCart) it gives me this.

https://ibb.co/KXH5tbq

It has empty body? But inside is not empty. They are displayed in shoppingCart list function with no issues but when I do a each function, it does not work. Any ways, how can I take these kinds of empty ones and the previous ones and add all those and count the total?

pickab00 left a reply on How To Count In Jquery Each Function

@JOSEFELIPETTO - https://ibb.co/8jwVL9v https://ibb.co/HDqC7bx

There are the images. Also why is there 2 objects?

I added 2 to basket. That is already displayed there. But why are there 2 objects. There are 2 shopItemId_23 with each console log. I am just console logging on click of add to basket button. So either way it is outputting the shoppingCart details.

Some do not update when added to basket. I mean I do not see the console log but when I open my basket, it is there

pickab00 left a reply on How To Count In Jquery Each Function

@VILFAGO - I am using an onclick. Here,

function buyItem() { var qty = $("#shopItem_qty_inputfield").val(); if(qty == "" || qty == 0) { removeItem(); return; }

    var item = shoppingCart[sel_shopItemId];
    item.qty = qty;

    $(sel_shopItem_elm).parent("li").find(".shopcart-icon").fadeIn();

    $("#shopItem_qty_container").slideDown().find("#shopItem_qty").text(item.qty);

    returnFromQtyInput();

}

pickab00 left a reply on How To Count In Jquery Each Function

@REALRANDYALLEN - Here is what it returns with the OP question,

{shopItemId: 23, price: 11, img: "ivdtestupdate2.jpg", langInfo: {…}, thumbnail: "ivd_test_thumb.jpg", …}

{shopItemId: 78, price: 20, img: "Spring Rolls & Samosa 2.jpg", langInfo: {…}, thumbnail: "Spring Rolls & Samosa thumb 2.jpg", …}

{shopItemId: 86, price: 30, img: "Primavera.jpg", langInfo: {…}, thumbnail: "Primaveratn.jpg", …}

Also, Sometimes it does not update the shoppingcart when I choose an Item. But when I select some other item other than that, it updates. But if I do a raw output of shoppingCart it shows all the items in the shopping cart even though the item is not being added. Hope I am making sense. So what I did was I refreshed shoppingcart every second to see changes and that works fine (this was just for testing). But my question is, why does it not console log when i press the buy button but it is still inside the basket even if it is not console logging.

pickab00 started a new conversation How To Count In Jquery Each Function

So here is my Jquery,

$.each(shoppingCart, function(k, v) {

    console.log(v);

  
});

On each select item for the shopping cart, it adds a new object in to the shoppingCart. Now how can I count the number of objects?

11 Jan
1 month ago

pickab00 started a new conversation Play All Videos In The Array

I am trying to make a playlist from html video tag and here is what I have so far.

var nextVideo = ["public/playlist/1.mp4", "public/playlist/2.mp4", "public/playlist/3.mp4"]; var curVideo = 0; var videoPlayer = document.getElementById('videoPlayer');

    if (nextVideo.length <= 1) {
        videoPlayer.loop = true;
        //console.log('one video can not be played');
    }
    videoPlayer.onended = function(){
        if(curVideo == 0){

                videoPlayer.src = nextVideo[1];
                curVideo = 1;


        } else if(curVideo == 1){
            videoPlayer.src = nextVideo[0];
            curVideo = 0;
        }
    }

And the HTML

            <video style="width:860px; height:580px;" controls autoplay id="videoPlayer">
                <source src="public/playlist/1.mp4" type="video/mp4">
                Your browser does not support the video tag.
            </video>

My problem is that after the main video <source> file has been played, it only loads the video 1 and 2 from the array of js. It does not play 1. What I want is to play all the videos in the array. And something wierd. I added:

if (nextVideo.length <= 1) {
        videoPlayer.loop = true;
        //console.log('one video can not be played');
    }

because if I have one video in <source> and if I have one video in the array, it plays only the <source> file and ends it there. How can I repeat the array even if it has only one video. And most importantly how can I play all the videos in the array and not skip any.

Thanks

10 Jan
1 month ago

pickab00 left a reply on Remove Specific Value From Json And Add The Array To List

@LOSTDREAMER_NL - One more question. What if I wanted to take only 3 results? Currently it is 4 so I wanted to take only 4.

pickab00 left a reply on Remove Specific Value From Json And Add The Array To List

@LOSTDREAMER_NL - Slipped my mind I guess. Thanks for this!

pickab00 started a new conversation Remove Specific Value From Json And Add The Array To List

So I want to be able to remove all the json with a condition and add the rest to the ul li. Here is what I have so far which does not seem to work.

$.ajax({
            type: "GET",
            url: "http://127.0.0.1/ECH3/assets/files/display",
            cache: false,
            success: function(response) {
            
            $.each(JSON.parse(response), function () {
                
                if(this.number == 'NIL'){
                    //console.log("");
                }else {
                    console.log("number: " + this.number + "  Room: " + this.call_number);
                    var pusher = $(this).push('<li>'+this.number+'</li>');
                    
                    $('#array').append(pusher);
                }
                
            
    
            });
            }
        });

The #array is simply <ul id="array"></ul>. And here is the json.

[{"call_id":65418,"number":5001,"call_number":5001,"counter":"Refraction Room 3"},{"call_id":65412,"number":5000,"call_number":5000,"counter":"Refraction Room 3"},{"call_id":"NIL","number":"NIL","call_number":"NIL","counter":"NIL"},{"call_id":"NIL","number":"NIL","call_number":"NIL","counter":"NIL"}]
05 Jan
1 month ago

pickab00 left a reply on Detach And Re Attach An Element JQuery

@REALRANDYALLEN - Yes it did a lot more sense. I thought of how annoying it would be to loop through the menu items from the database as well. So flex was the better choice. Thanks again :)

pickab00 left a reply on Detach And Re Attach An Element JQuery

@REALRANDYALLEN - I actually took your advice and changed the cols to flexbox and used media queries to fit them in to different view ports. Thanks!

pickab00 left a reply on Detach And Re Attach An Element JQuery

@REALRANDYALLEN - Ok can you at lease point me in to the right direction on this? Here is what I am trying now. Basically when I search, it adds display:none; to the elements which are hidden. But when I try this,

if ($('.first-column ul li > :hidden').length <= 0) {
                console.log('empty');
            }

it does not work. The .first-column is the first col-sm-6 and I am trying to count the hidden elements and if the count of hidden elements are smaller than or equal to 0, it does not work. It just gives me 'empty' when there are still non hidden elements. And if I keep hitting backspace repeatedly even after the input is empty, it console logs 'empty'. I want to know why this happens and how to make that work at least.

pickab00 started a new conversation Detach And Re Attach An Element JQuery

So I have a live search which I am working on. And I was wondering why my detach() won't bring back the attachment after removing it. Basically the problem for me is that I hace two col-md-6 which handles two rows which displays many data (6 per column). My issue is that When I live search, the second column shows the items which matches the search result and the first column is blank (because the first column does not contain any which matches the search result). But it looks wierd as there is a huge gap in between and the results shows only on the second column. Here is an image example.

This is the default one,

https://imgur.com/8WwDr8K

And here is the searched one with the result,

https://imgur.com/byTuWZJ

As mentioned above, the first column stays empty so it takes that space. What I want is the items to move to first column if it is not already there. Here is my HTML,

  • MVR 25.99 Add to Basket

    Grilled Beef with potatoes

    Meat / Potatoes / Rice / Tomatoe

  • MVR 30.99 Select Options

    Tuna Roast Source

    Tuna / Potatoes / Rice

  • MVR 40.00

    Roast Beef (4 sticks)

    Crab / Potatoes / Rice

  • MVR 20.50

    Salted Fried Chicken

    Crab / Potatoes / Rice

  • MVR 20.50

    Lumpia Shanghai

    Crab / Potatoes / Rice

  • MVR 20.50

    Chicken Adobo

    Crab / Potatoes / Rice

  • MVR 25.99

    Marinated Beef

    Meat / Potatoes / Rice / Tomatoe

  • MVR 30.99

    Fried Tokwa

    Tuna / Potatoes / Rice

  • MVR 40.00

    Letson Kawali

    Crab / Potatoes / Rice

  • MVR 20.50

    Fried Pork

    Crab / Potatoes / Rice

  • MVR 20.50

    Chopsuey

    Crab / Potatoes / Rice

  • MVR 20.50

    Sunny sideup egg

    Crab / Potatoes / Rice

And my Jquery for live search,

jQuery(document).ready(function($){

        $('.live-search-list li').each(function(){
            $(this).attr('data-search-term', $(this).text().toLowerCase());
        });

        $('.live-search').on('keyup', function(){

            var searchTerm = $(this).val().toLowerCase();

            $('.live-search-list li').each(function(){

                if ($(this).filter('[data-search-term *= ' + searchTerm + ']').length > 0 || searchTerm.length < 1) {
                    $(this).show();
                } else {
                    $(this).hide();
                }

            });

        });



    });

As you can see in html I have two col-md-6. Sorry about the long code.

04 Jan
1 month ago

pickab00 left a reply on How To Insert Form Data When There Is Multiple Form

@JLRDW - Thanks. That pretty much sums up what I’ll do from here on. Though at this point I am not sure which to select as the best answer haha

pickab00 left a reply on How To Insert Form Data When There Is Multiple Form

@JLRDW - Each modal is for each item separately. So that means when a menu item is clicked, the modal shows up for that menu item. So having 20 modals in my html. Thats what bothers me. And wrapping them in a form. That is what i am asking. Is it a wise idea to do so?

pickab00 left a reply on How To Insert Form Data When There Is Multiple Form

@JLRDW - Ok I’m really bad at explaining. What do you mean by a modal per table? Ok so i have looped 20 menu items in to my blade. Now I want to be able to have modals for those 20 menu items. Do I have a modal for each of the menu item? Please reffer to the image linked. That will explain what “menu item” means. And that add to basket button displays a modal for each button press. That is what I am asking. Each button press triggers a separate modal which is linked to that button. Should I do that? And should I wrap each of the modals in a form so i can pass the values inside of the modal to the controller via ajax or not using ajax (which ever is fine). So the main question is should i loop a separate modal for each menu item (20 items). And should i wrap the modals in form so there are separate forms which i can then send to the controller with the filled details from the modal. Hope that makes sense

pickab00 left a reply on How To Insert Form Data When There Is Multiple Form

@JLRDW - Yes that I understand but one thing confuses me. The modals I mentioned right? Should I create modals for each menu item? I mean there are about 20 menu items with it’s properties which need to be displayed. So that means when i loop, it creates 20 modals? Is this wise to do?

pickab00 left a reply on How To Insert Form Data When There Is Multiple Form

@JLRDW - Ok i will have a go at this. Thaks!

pickab00 left a reply on How To Insert Form Data When There Is Multiple Form

@JLRDW - About that. What did you mean by looping json? Also, is it wise to output json data directly from the db? I mean let’s say if I decide to use ajax to call a link, it will show the json of the table data with it’s relations. Is it wise to do that? That would lead to leaking of the db structure wouldn’t it?

pickab00 started a new conversation How To Insert Form Data When There Is Multiple Form

So I have a bunch of looped "menu items". Each of these items has it's properties. Some do and some don't. Below is a screenshot of the looped menu items. In the screenshot there are 4 but there is a lot more than 4.

https://imgur.com/a/MWfJ2Ly

And here is what happens when I press the "add to basket" button. It displays a modal (bootstrap). Like I mentioned before, some menu items will have these options pop up and some don't. Here it is,

https://imgur.com/a/87FdIKI

The thing is that each of these modals are supposed to be a form which submits some data on click. Now this is not the right way I suppose as that is a lot of forms on the page. Suppose we had 14 menu items which had some properties. Then that would mean that each of the 14 menu items will have its own <form> with action="insert/id_goes_here". Now my first question is, what would be the better way of doing this? And second, if suppose I am using ajax or something, how can I take the properties with it? By properties I mean there are some other tables data which are related to this. For an example, some menu items may have properties to be selected like toppings, flavors, size etc... So I wanted the user to select those options from the pop up. Each pop up being a separate form. Sorry if this was too lengthy.

PS. Please do not hate me for the heading :) Didn't know exactly what to write

pickab00 left a reply on How To Update Multiple Forms

How about creating a form onclick of the item button. I mean creating the form which relates to that menu item and as soon as it is done posting, destroy that form. Obviously it is a bad approach to have 50 forms in my html for each of my item looped. I am not that experienced with vue so what about this approach?

03 Jan
1 month ago

pickab00 left a reply on How To Hide Element Inside Of The Parent Div

@REALRANDYALLEN - This works flawlessly. Thanks a million times!

pickab00 left a reply on How To Hide Element Inside Of The Parent Div

@REALRANDYALLEN - Here is the issue with some more detail. I do not know what is going on here. Here is the image of it without any input/searches. So this is how it looks like by default.

https://ibb.co/9WYwyV8

And here is the search result for "live" which is the very first item. This does not show the header.

https://ibb.co/QkrBPYj

But here is the fourth item which shows the header perfectly fine

https://ibb.co/4ttYZvk

And lastly when I search "james" it messes everything. No header on the first search result and the second one has the header but it combines the rest of the stuff with the second header.

https://ibb.co/sW801FM

pickab00 left a reply on How To Hide Element Inside Of The Parent Div

@REALRANDYALLEN - Actually there is an issue still. The above comment. I have attached an image too.

pickab00 left a reply on How To Hide Element Inside Of The Parent Div

@REALRANDYALLEN - Okay please don't hate me for this. And sorry for the wasted time. It was an issue on my end. I forgot just a tiny bit of call to be added. But here is the results I am getting with the corrected version just the same as the above. I mean your code (the one before the optimized one). And the HTML (the corrected version).

https://ibb.co/B2XKsHW

Again, so sorry!

pickab00 left a reply on How To Hide Element Inside Of The Parent Div

@REALRANDYALLEN - The above does not display any results now. What I meant was, your previous code worked fine. But I wanted to remove all the category headers hide and show only the category header which belongs to the result. Like if the result is "green tea" and the header is "Tea's" then show only "Tea's" and remove all the rest. I mean keep the headers which belongs to the search results only. Hope this makes more sense. I am bad at explanations though it makes sense in my head.

pickab00 left a reply on How To Hide Element Inside Of The Parent Div

@REALRANDYALLEN - This works perfectly. Just one issue. I want to hide the rest of the category headings. But leave the currently search result related category.

I want to do this so I can put in to an inner div if the result is 0 "No result found" or something. Also to clean up the view as there are a lot of categories.

pickab00 left a reply on How To Hide Element Inside Of The Parent Div

@REALRANDYALLEN - How is your structure? Here is my full code of jquery,

jQuery(document).ready(function($){

        $('.live-search .col-md-6').each(function(){
            $(this).attr('data-search-term', $(this).text().toLowerCase());
        });

        $('.live-search-box').on('keyup', function(){

            var searchTerm = $(this).val().toLowerCase();

            $('.live-search .col-md-6').each(function(){

                if ($(this).filter('[data-search-term *= ' + searchTerm + ']').length > 0 || searchTerm.length < 1) {
                    $(this).show();
                  
                    $(this).parents(".menu-item-wrapper").find('.menu-item-category').hide();
                } else {
                    $(this).hide();
                   
                }



            });

        });

    });

pickab00 left a reply on How To Hide Element Inside Of The Parent Div

@REALRANDYALLEN - This works but only for the first one only. The rest of the wrappers does not work.

pickab00 started a new conversation How To Hide Element Inside Of The Parent Div

I am using JQuery to hide the element inside of the parent div. Here is my HTML.

<div class="menu-item-wrapper">
            <div class="row">
                <div class="col align-self-center">
                    <h3 class="menu-item-category">1 Dashboard</h3>
                </div>

            </div>

            <!-- Row -->
            <div class="row live-search">
                <!-- Column -->
                <div class="col-md-6 col-lg-3 col-sm-6">
                    <div class="card">
                        <img class="card-img" src="../assets/images/background/socialbg.jpg" alt="Card image">
                        <div class="card-img-overlay card-inverse social-profile d-flex ">
                            <div class="align-self-center">
                                <h4 class="card-title menu-title">live Anderson</h4>
                                <p class="text-white">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt </p>
                                <p class="text-white price-tag">MVR 150/-</p>
                                <div class="add-to-basket-wrapper">
                                    <input type="number" class="add-to-basket" value="1">
                                    <div class="clearfix"></div>
                                    <button type="button" class="btn btn-success waves-effect waves-dark">Add to Basket</button>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
</div>
</dv>

And my JQuery,

$(this).parent().find('.row').hide();

$(this) being $('.live-search .col-md-6').each. As you may have guessed, I have multiples of the above code (being iterated via php). So how can I say that I want to hide the menu-item-category which is inside of the current menu-item-wrapper. Like I mentioned, I have multiple of these and I am doing a live search and I want to show only the menu-item-category which belongs to that search result.

pickab00 started a new conversation How To Update Multiple Forms

I am looking for the most optimal way of updating multiple forms. Here is what I have.

I am foreach looping through some of the data which has some options which the users can select. The loop has a bootstrap modal tied to each of it. So basically each item I am looping has it's own set of multiple options which opens in a modal. So my question is, how can I submit these multiple modal forms? Do I use AJAX? Do I use just plain form looping and make multiple forms with each of it's ID attached (eg action="insert/12"). What would be the better/cleaner way to achieve this.

02 Jan
1 month ago

pickab00 left a reply on Help With A Db Structure

@SHEZ1983 - I was thinking of a pivot table. There will be a table for types of options. Types will store things like “toppings”, “falvours” etc... And then there will be a table called options. This will be linked to the type and will have options for each type. Like “lettuce”, “tomato” etc... And finally we use a pivot table between options and menu items. That way, a menu item could have many options. And that specified option would belong to a type. I do not see the point of wasting so much data on creating options for each menu item on a separate table. This way, I can manage the db a lot more efficiently and understand whats going on. And in case if I were to add anything in the future (lets say a new type) it would be a lot easier to add. And of course the managers will have to just tick some options when adding new available menu items. It would be easier for them too. Types and options would be almost the same across all menu items. Some may change but most of them will stay the same. That is why I think a pivot table and exta 2 tables will solve this more than efficiently. Am I on the right track?

01 Jan
1 month ago

pickab00 left a reply on Help With A Db Structure

@RUTVIK106 - So basically I can have many “options” for each of the items correct? I can just create a table and add as much options as I want to a menu item. But the other question is, what table will the user have? Now the user has a table called “order” which stores all the order information like the menu item id and so on. Now I can show the options available for the user with the method above. But where will I store the user selected option in?

pickab00 started a new conversation Help With A Db Structure

So I am trying to make an app for Restaurant. And I am stuck at the Menu. Here is what I have so far. Basically there are categories and each category has many menu Items. So in this case, the category is a table and menu item is a table. menu item table will have category_id in it and it is a one to many relationship. So far so good. The structure I am not getting is this. I want the restaurant managers to be able to add their own menu item customization. In the sense, when the user clicks a menu Item, they will be asked to choose some settings. Lets say, "Medium", "Small", "Large" etc... This may vary as there might be other options like "Lettuce", "Tomato" etc...

What I do not get is, what table I should create and how to link them. What kind of a relationship it is. Also the restaurant managers can change these options for each of the menu Items.

Any help would be greatly appreciated :)

31 Dec
1 month ago

pickab00 left a reply on Getting Ajax Undefined Response

Perhaps. Thanks again :)

pickab00 left a reply on Getting Ajax Undefined Response

This works perfectly. Thanks! Though I do not understand why caps won't work

pickab00 started a new conversation Getting Ajax Undefined Response

I keep getting undefined when I try to take a specific value from my response. Here is my response.

{Title: "Need for Speed", Year: "2014", Rated: "PG-13", Released: "2014-03-14", Runtime: 132,…}
Actors: ["Aaron Paul", "Dominic Cooper", "Imogen Poots", "Kid Cudi"]
Awards: "1 win & 2 nominations."
BoxOffice: ",138,026"
Country: ["USA", "India", "UK", "France", "Philippines"]
DVD: "05 Aug 2014"
Director: "Scott Waugh"
Genre: ["Action", "Crime", "Thriller"]
Language: "English"
Metascore: 39
Plot: "Framed by an ex-partner for a murder he did not commit, Tobey Marshall, a     financially struggling custom-car builder and street-racer, spends two years in jail thinking     about one moment. Fresh out of prison he reacquires the fastest car his workshop ever built     and sold, and seeks to enter a secretive and extremely high-stakes race known as The DeLeon.     His purpose; redemption, recognition from the world of racing and to solve his problems. Yet     all this fades in comparison to his driving reason. Revenge. Above all, revenge. This is a story     about love, redemption, revenge and motor oil all swirled together"
Poster: "https://m.media-    amazon.com/images/M/[email protected]_V1_S    X300.jpg"
Production: "Walt Disney Studios"
Rated: "PG-13"
Ratings: [{Source: "Internet Movie Database", Value: "6.5/10"}, {Source: "Rotten Tomatoes",         Value: "23%"},…]
Released: "2014-03-14"
Response: true
Runtime: 132
Title: "Need for Speed"
Type: "movie"
Website: "http://TheNeedForSpeedMovie.com"
Writer: ["George Gatins (screenplay)", "George Gatins (story)", "John Gatins (story)"]
Year: "2014"
imdbID: "tt2369135"
imdbRating: 6.5
imdbVotes: 152182
tomatoConsensus: null
tomatoFresh: null
tomatoImage: null
tomatoMeter: null
tomatoRating: null
tomatoReviews: null
tomatoRotten: null
tomatoURL: "http://www.rottentomatoes.com/m/need_for_speed/"
tomatoUserMeter: null
tomatoUserRating: null
tomatoUserReviews: null

And here is my AJAX,

$.ajax({
    //type: "POST",
    url: "http://127.0.0.1:8001/omdb/search.php",
    dataType: "JSON",
    data: { search: param},
    
    success: function(data) {

        //Set data.name.
        //$(".title").val(data.Title);

   
            console.log(data.Title);
    }


});

I am trying to get the title but it shows undefined. Using just data gives me the json.

27 Dec
1 month ago

pickab00 started a new conversation AJAX Passed Id Same Even If It Is Manually Changed

This is more of a confusion than a problem. I want to clear this doubt. So I have an ajax which sends a data to the controller and thus the controller checks if the $id exists or not. Here is my ajax,

var product_id = $(this).data('id');
var gem = $('.gem').data('r');
var url = "/addToCart/"+product_id+ '/' +gem;

$.ajax({

            type: "POST",
            url: url,
            data: {
                qty: qty,
            },
            success: function (data) {
                console.log(data);

            },
            error: function (data) {
                console.log('Error:', data);
            }
        });

And the HTML,

<button data-id="{{$menuItems->id}}" class="addCart">Add To Cart</button>

So everytime the user clicks the button, ajax then takes the {{$menuItems->id}} (this is a loop) and passes it to the controller. Or the route url. The url has two parameters. One is the item code product_id and the other is a code from db gem. Now this is why I am not passing any of the data from ajax. Because I can simply pull it out from the controller function, like so,

public function addToCart($id, $code, Request $request) {

    $menuItem = Menuitem::findOrFail($id);

  
    //bla bla and so on do the rest down below

return "Worked!" . $menuItem->item_name;

}

Now the confusion I am having is this. Clearly the $menuItem = Menuitem::findOrFail($id); will fail if the product_id inside the url does not exist. This works perfectly fine. If I change the buttons data-id="454545" which does not exist, it gives me a 404 error. But here is the thing. If I click the button while the data-id="1" (which exists) and then after it has successfully sent that data to the controller and db, and then if I change that data-id="54545" (which does not exist), it still sends the id 1. Am I missing something here or is this how ajax works? If I don't press the button first and then change the data-id="65454" it gives me 404. But If I click the button and after it is successful, then even if I change the data-id="21215125" it still returns id 1. Why is that?

Phew. Such a long post for a short question. Sorry guys. Am I missing something here? Is it caching?

pickab00 left a reply on Trouble With "Add To Cart"

@VAJID - Mine does not work because I have multiple first ul so it works the same as using parent. Here is my full html,

<ul>
    @foreach($menuCategory as $menuCategories)
    <li>
        {{$menuCategories->name}}
        <ul>
            @foreach($menuCategories->menuitems as $menuItems)
            <li>{{$menuItems->item_name}}</li>
            
            <input type="number" class="qty" data-qty="{{$menuItems->price}}">
            <button data-qty="{{$menuItems->price}}" data-id="{{$menuItems->id}}" class="addCart">Add To Cart</button>
            @endforeach
        </ul>
    </li>
    @endforeach
</ul>

pickab00 left a reply on Trouble With "Add To Cart"

@VAJID - One more question. Will using this method at all have any security problems? As I am not sending a form, what about csrf? I already have it setup with ajax but will this give a chance to break anything or some one to exploit anything

pickab00 left a reply on Trouble With "Add To Cart"

@VAJID - This does not work. Still the same result

pickab00 left a reply on Trouble With "Add To Cart"

@VAJID - This works perfectly. Thanks! Though I had <li>. using that does not work as I had something like this,

<ul>
<li>

    <ul>
    
        <li>
        <input type="text" class="qty" placeholder="Enter quantity" data-qty="{{$menuItems->price}}">
<button  data-id="{{$menuItems->id}}" class="addCart">Add To Cart</button>
        </li>       

    </ul>

</li>
</ul>

pickab00 left a reply on Trouble With "Add To Cart"

@VAJID - The data-qty="{{$menuItems->price}}" was for testing as mentioned. I do not want the pricing. I want the user to be able to input the quantity. So that would require an input field right? Now my doubt is that when I use input fields, How can I take that input field value for that button press and send it to controller. The question above has an input field which I want the user to type a number and that number will be taken with the press of the button. Lets say if the user enter "2" in to the first input field and click on button 1, the output to controller will be 2. And if the user enters "3" on the second input field and clicks button 2, the output to controller will be 2.