0

Well I have these lines.

....
if(isAvailable()){alert("available")}; 
....

//check if ajax value returned. if any data returned means out of stock.
function resolver(itemName, itemId){
   $.get({ 
       url: "/example.com/well",
       data: { ItemName:itemName, ItemId:itemId }
   }).done(function(data){if(data){return false;} else {return true;}});
 }



 function isAvailable(){

    var itemName = 'coke-zero';
    var itemId = 1234;

    //use resolver to return availability.
    if(!($('#qty option:selected').text() == false)){
        return resolver(itemName, itemId);
    }
    //if no qty sat, doesn't matter return true; 
    return true;
 };

I tried to check if product is in stock and if it's in stock, alert "available". To do so, I use JQuery ajax call. #Qty check is to see if user input value is greater then 0. If quantity is greater than 0 I run ajax function. Ajax return ** out-of-stock product name **. If product name is returned, isAvailable() function should return false and prevent alerting "available".

I know I am not being very clear explaining what I am trying to do. But if anybody can help me out, it would be greatly appreciated.

currently isAvailable() is a type of undefined.

learnNetsuite
  • 47
  • 1
  • 1
  • 5

0 Answers0