/    Sign up×
Community /Pin to ProfileBookmark

Not getting results to pop up in modal

so my script is loading, and the loadbar is running but the final result of the estimate is not coming through any thoughts?

[CODE]jq_1_11(function(){
var el = document.getElementById(‘checkAvailability’);

if(el !== null) {
el.addEventListener(‘click’, function(event){
event.preventDefault();

var modal = new Modal({});
var loader = “<img src=’https://d13yacurqjgara.cloudfront.net/users/12755/screenshots/1037374/hex-loader2.gif’>”;
modal.options.content = loader;
modal.open();

// get the quantity
var quantity = document.getElementById(‘request_qty’).value;

// get the itemid
var itemid = this.getAttribute(“data-itemid”);

getAvailability(itemid, quantity).then(function(data){
var content = generateTable(data, quantity);

modal.options.content = content;
modal.redraw();
});
});
}

/**
* Function to test functionality.
* @return {[type]} [description]
*/
function test() {
var body = document.getElementsByTagName(‘body’)[0];

body.addEventListener(‘fire’, function(){
var modal = new Modal({});
var loader = “<img src=’https://d13yacurqjgara.cloudfront.net/users/12755/screenshots/1037374/hex-loader2.gif’>”;
modal.options.content = loader;
modal.open();

// get the quantity
var quantity = 10;

// get the itemid
var itemid = 9637;

getAvailability(itemid, quantity).then(function(data){
var content = generateTable(data, quantity);

modal.options.content = content;
modal.redraw();
});
});
};

test();

/**
* Get the availability data for the item
* @return {[type]} [description]
*/
function getAvailability(itemid){
return jq_1_11.ajax({
url: “/app/site/hosting/scriptlet.nl?script=46&deploy=1”,
type : ‘get’,
data : {‘id’ : itemid}
});
}

function generateTable(response, request_qty)
{
var content = “”;
if(response.error_code != undefined) {
content = “<div>” + response.error_msg + “</div>”;
} else if (response.no_results != undefined) {
content = “<div>” + response.no_results + “</div>”;
} else if (response.results && response.results.length > 0) {

content += ‘<div class=”table-pop”>’;
content += ‘<div class=”table-pop-title”>’;
content += ‘<div class=”pop-left”>Request Quantity</div>’;
content += ‘<div class=”pop-right”>’ + request_qty + ‘</div>’;
content += ‘</div>’;
content += ‘<div class=”table-pop-content”>’;

// if it is a matrix item
if(response.results.length > 1) {
for(var i in response.results)
{
var item_data = response.results[i];
// only process the childs
if(item_data.internalid !== “”) {
var qty_available = parseInt(item_data.quantityavailable);

var qty_available = parseInt(item_data.quantityavailable);
var available;
if(qty_available >= 5000){
available = ‘Please call for inventory availability’;
}

var available = ‘Please call for inventory availability’;

if( ! isNaN(qty_available)) {
var balance = qty_available – request_qty;

if(balance >= 0) {
available = “Available”;
}
}

var row = ‘<div class=”pop-left-cont”>’ + item_data.itemid + ‘</div>’;
row += ‘<div class=”pop-right-cont”>’ + available + ‘</div>’;

content += row;
}
}
} else {
for(var i in response.results)
{
var item_data = response.results[i];
var qty_available = parseInt(item_data.quantityavailable);
var available;
if(qty_available >= 5000){
available = ‘Please call for inventory availability’;
}

if( ! isNaN(qty_available)) {
var balance = qty_available – request_qty;

if(balance >= 0) {
available = “Available”;
}
}

var row = ‘<div class=”pop-left-cont”>’ + item_data.itemid + ‘</div>’;
row += ‘<div class=”pop-right-cont”>’ + available + ‘</div>’;

content += row;
}
}

// if it is an inventory item

content += ‘</div>’;
content += ‘</div>’;

}

return content;
}
});[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FrontEndDev99Feb 17.2016 — Some basics first...Are you running this on a Apache server?
×

Success!

Help @Designer525 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...