79347396

Date: 2025-01-11 02:08:25
Score: 2
Natty:
Report link

@Olumuyiwa Thank you for your input. Your comment about the variables not being set was spot on. I changed the Ajax call as you suggested. I included the whole function:

            $('#price').on('blur', function(){
              var get_pn = document.getElementById('search_item').value;
              var new_price = document.getElementById('price').value;

                $.ajax({
                    url: "/search_item_new_price",
                    data: { search_item: get_pn},
                    type: 'GET',
                    success: function(data){
                        var our_cost = data.our_cost;
                        var item_id = data.id
                        if (new_price !== our_cost) {
                            let result = confirm("Change the price for item number " + get_pn + " to " + '$'+ new_price + "?");
                            if (result === true){

                                data = {
                                    id: item_id,
                                    our_cost: new_price,
                                    _token: "{{csrf_token()}}",
                                };
                                $.ajax({
                                    url: "/change_item_price/" + item_id,
                                    data: data,
                                    type: 'POST',
                                    success: function( data ) {
                                       //  console.log(data);
                                    }
                                });
                            }
                        }
                    }
                });
            })

Reasons:
  • Blacklisted phrase (0.5): Thank you
  • Long answer (-1):
  • Has code block (-0.5):
  • User mentioned (1): @Olumuyiwa
  • Self-answer (0.5):
  • Looks like a comment (1):
  • Low reputation (0.5):
Posted by: T.A.