@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);
}
});
}
}
}
});
})